Hot answers tagged

17

Since the question is quite broad I'll try to summarise the advantages of the template partials pattern in general and Stash embeds in particular. Template partials allows code to be encapsulated into reusable chunks, to help you respect the DRY principle allows markup (the 'view') to be separated from the code that retrieves and formats your data (the '...


13

You'll probably need to show more of your template code but where Stash could benefit you is that you could use a single channel entries tag to output both the single entry view data and the recent blog posts at the same time. Here's a good example from Mark Croxton which shows how he approaches a similar thing.


12

Native caching in EE basically comes down to: Tag Caching Query Caching Template Caching “Morsel” Caching Static Page Caching All 5 types are explained in detail in this article on EEinsider: http://eeinsider.com/articles/using-cache-wisely-with-expressionengine/ Third party solutions include: CE Cache http://www.causingeffect.com/software/...


10

Since Git can currently only stage files and not empty directories, the only purely Git based solution is to do as you are now. An alternative approach is to include a bash script in your repo that creates any required cache directories if the do not exist and (importantly) sets permissions on these directories (which often needs to be 755/777). The ...


10

It's hard to tell what you're trying to achieve with Stash in that code sample. Since you are both 'setting' and 'getting' in the same place you aren't benefiting from a separation of markup and data, and as you're not using any caching you won't see any performance benefits either. Here's a quick example that would add caching for subsequent requests: {...


10

"I am using Stash only recently and was wondering how the performance is boosted over using embeds? I know there are a few less queries used in general, and I know you can subvert the parse order, but is there better reason to use it in templates?" Those were some of my own questions and with a couple of podcast from Lea Alcantara and Emily Lewis I got them ...


10

You can use the {exp:stash:destroy} {or it's alias {exp:stash:unset}) to unset a cached variable or variables within an entire scope (user or site): https://github.com/croxton/Stash/tree/dev#expstashunset-requires-php-523-or-expstashdestroy Here's an example of use to clear cached comments when a new comment is submitted: https://gist.github.com/3973821 ...


9

Personally I recommend avoiding all current native EE caching systems and highly recommend investing in one or more of the already mentioned 3rd party caching systems. EE v2 did little if anything to make the dated EE v1 caching systems modern in any way, even if the CI framework has more modern caching systems available to it.


9

The other answers are going about this a slightly convoluted way. You don't need a special .gitignore in each folder, and that makes it hard for other developers to figure out what's going on (or you in a few months). Just ignore the whole cache folder in your root .gitignore: $ cd /path/to/root $ echo "system/expressionengine/cache/" >> .gitignore ...


8

A possibly cleaner way would be to have it in your .gitignore at the root level of your repo... system/expressionengine/cache/* !system/expressionengine/cache/.gitignore ... that way everything's centralized in that one .gitignore. However it's my preferred method to have multiple .gitignore files (like your example above), one in each "empty" directory ...


6

The performance gains are not just about using fewer embeds, they're equally about using fewer channel:entries tags, which are expensive. Your example is obviously not a complete web page, but if it were, how would you set the page's title and meta data and any other dynamic stuff that belongs in the <head>? How would you send related dynamic content ...


5

Files are written to the static cache directory by Stash - you don't put files in there. Typically these cached files would be your fully rendered HTML pages. This is the opposite of the stash template directory, where you add template files (containing EE tags, variables etc.) which are read by Stash. After creating a folder called 'static_cache' (or ...


5

As you say, automatic cache breaking is very nice, and IMHO a must, since anything else is bound to impact the user experience for the editors. My goto caching addon since its release has been CE Cache, which solves this nicely. For my 4–5 latest projects I've used the Template Partials approach (with Stash) increasingly. I love this way to develop in ...


5

Like Bhashkar said, that code should work in either a PHP-enabled template or put in a plugin and then put in a template. Then call the template to clear cache. A more advanced way, and probably the proper way to do it, is to create a simple module, which can use an Action URL. Stephen Lewis wrote a blog post about what Actions are. Basically, an action ...


4

We use a single .gitignore file in the root directory, and we specifically list all subfolders. This way, the cache folder can contain the default index.html file, and will be indexed by git. system/expressionengine/cache/ee_version/ system/expressionengine/cache/ee_version/current_version system/expressionengine/cache/tag_cache system/expressionengine/...


4

I don't think there are any add-ons available currently modify the headers for caching. There is, however, HTTP Header, by Rob Sanchez that you could use as a basis to do this. It wouldn't be very difficult to modify HTTP Header to include additional header options, or you could turn on PHP for your templates and place the code directly in the templates, ...


4

The session cache only lasts for a single page request. So by the time your action gets called, that cache is gone. You'd be better off adding those to the form as hidden fields, and then grabbing them from POST in your action.


4

I have run into this issue before and I was in the same boat. And "Static Page Caching" didn't do it for me, CE Cache did. I learned that I had to make sure I was really caching the site correctly, such as the right areas and embeds. Also I made sure that I wrote my markup in the best way I could to reduce queries. I hope this helps, I have always found ...


4

{exp:stash:static} caches the entire page to a static file. The cached output is not stored in the database. And you can't cache just a region / section of the page. When it works for you to use {exp:stash:static}, it should return pages noticeably faster than {exp:stash:cache}, and also (since the page requests route directly to the static file, without ...


4

ref: https://docs.expressionengine.com/latest/development/legacy/libraries/cache.html#class-methods ee()->cache->delete('/myaddon/');


3

Given that the Stash set is inside a loop, the resulting output would repeat your code above multiple times. Thus you would have multiple instance of {exp:stash:not_empty name='br_bulk'} and {exp:stash:br_bulk} in your template. The first instance of each of these will be parsed by EE, but subsequent instances will be replaced with a marker that will later ...


3

Although Stash doesn't currently have automated cache breaking you can use the {exp:stash:unset} tag (docs) to flush caches when certain actions occur. For an example of this in use take a look at the top of Mark Croxton's sample viewModel template, where it's used to clear out cached comment data when a new comment is submitted. The Stash::destroy method ...


3

is there any way to prevent the storage of, and/or automatically purge the files in ce_image_remote_dir? There is not a way to accomplish this with the default extension, but you could accomplish this with a custom one to meet your needs. PHP has to have a local copy of the image in order to manipulate it. Additionally, it's much faster to check whether ...


3

If you use that code in an EE template (rather than a Stash embed) then EE will parse {segment_1} early, before tags are run and before Stash can escape it. See step 1 here: http://loweblog.com/downloads/ee-parse-order.pdf The good news is you can access any global variable or snippet as a tag like this: {exp:stash:get name="segment_1" type="snippet"} ...


3

/system/codeigniter/system/libraries/Cache/Cache.php Has the Cache class - Check this file is on the staging server, also check the permissions. I've often had similar issues where it's related to case sensitivity and differing servers (my local not being case sensitive, the public servers are) - so also check that the folder and file are in the correct ...


3

Sorry for the trouble. This is an issue in EE 2.9 and will be fixed in the next release. For now, you can get around it by specifying the cache driver in your config.php: $config['cache_driver'] = 'memcached';


3

After speaking with Derek privately I was able to resolve the issue which is a permissions error. The steps taken to solve this are: Via FTP/SSH navigate to system/expressionengine/cache and delete everything with the exception of .htaccess and index.html . Afterwards, change your permissions on system/expressionengine/cache to be 777 then restart your ...


2

It turns out the problem was being caused by the lack of a simply setting in the CE Image tags. As Aaron from CE Image very helpfully pointed out, by adding remote_cache_time="360" CE Image automatically checks each thumbnail image every 360 minutes (or 6 hours) and overwrites it if the image has changed. Thanks to everyone for their suggestions!


2

You probably got errors because EE couldn't find the cache folder. I'm new to git, and I have all my ignore rules in one file in the root and there I have this # Cache /ee-admin/expressionengine/cache/* /public_html/cache/*


2

Sorry to throw a cat amongst the pigeons but stash is very much a purist approach. Sure there are advantages of it but it takes a multi designed and structured site to a whole new level of complexity. For me and now... Low Variables will do for the performance hit of embeds.


Only top voted, non community-wiki answers of a minimum length are eligible