5

I've been thinking about creating the simplest possible cache solution and would like to know if this is a worthwhile option.

Using the outstanding cacheflag plugin, I place the entire layout wrapper template inside these tags:

{% cacheflag flagged "content" globally using key craft.request.path %}
 ... lots o code....
{% endcacheflag %}

In the back end, I flag each of the section with a "content" flag.

I think by doing this, each url should have it's own cache file. And all caches are cleared whenever a new entry is posted.

Granted it may a bit of a sledgehammer style solution, but if traffic is average it could perhaps be effective?

Is my understanding correct or is this a bad idea?

mjr
  • 1,405
  • 13
  • 21

1 Answers1

2

In my opinion it's a good, easy and fast way to caching content. We use similar solutions on different Websites and it works perfect for us. Maybe you should do a more specific flagging to avoid deleting all cached entries at once. And you should take care about possible dynamic code parts like forms.

Brad Bell
  • 67,440
  • 6
  • 73
  • 143
Tom Bauer
  • 1,327
  • 7
  • 14
  • Thanks for the feedback! Have you had any issues with image transforms in your caching approach? – mjr Jun 16 '16 at 13:41
  • Jep, we had once some issues with image transforms. We used generateTransformsBeforePageLoad => true in our general config and sometimes (not traceable) the image transform was not created. Changing back to the default generateTransformsBeforePageLoad => false fixed this problem. The Craft caching is clever and stores the cache only if no temporary transform url is in the content. – Tom Bauer Jun 17 '16 at 07:25