3

I am new to Stash's saving/caching system and from what I've seen so far it looks really useful.

Here's my thinking: I have a special offers section on a site, in the immediate future it is likely to have hundreds of entries in it.

Would this be the correct course of action?

  1. Set a stash list called "special-offers" and grab all of the data from a channel entry loop and save that with the scope of site
  2. Put that into a snippet, {sn_set_special-offers} and call this whenever I need a special offer
  3. Whenever I need to read from that list, for example an individual special offer page I would use match="#{segment_2}#" against="url_title"} to emultate dynamic="yes"

Is this the correct way of doing things? To grab all of the data from EE channels into a stash list, cache that away and then use get_list whenever data is needed?

3

I don't tend to use Stash to duplicate the data model. In this case you would be adding a close coupling between the generation of the list and the individual offer pages. That adds fragility. As far as possible you should separate the functionality and presentation of your site into components that are not dependent on one other. You can and should still make reusable snippets of code but they should be generic and modular.

In this instance I would capture the list and use it wherever a list of offers is needed. The individual offer pages I would cache independently with full page caching.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.