1

I have a large site that uses Structure for most of the static page content. I'm also using CE Cache for performance on those pages since some of them are pretty complicated and heavy.

I'm using the database driver.

Since the content doesn't change very frequently I have the cache set to never refresh. So far I've been forced to manually clear the cache for a specific content path since clearing the entire site cache just for one small section of the site seemed wasteful.

Since the site's secondary navigation shows the current section's pages and immediate siblings, the cache would need to be flushed for the current section as well as one level up just in case the structure URL changes. (see screenshot)

secondary navigation screenshot

Is there a way to configure Cache Breaking in such a way that I can automatically clear all pages that are siblings as well as the immediate parents and their siblings?

3 Answers 3

3

I think the best way to approach this is to tag the caches with their sibling ids. Structure actually makes this quite easy, because of its global variables:

{exp:ce_cache:it tags="{structure:sibling_ids}|{structure:page:entry_id}"}
    {exp:channel:entries limit="1" ...}
        ...
        {exp:ce_cache:add_tag}{entry_id}{/exp:ce_cache:add_tag}
    {/exp:channel:entries}
{/exp:ce_cache:it}
3
  • 1
    Thanks, this has me thinking but I'm still not 100% on the cache breaking rules. Would I add a rule to the "Items" side and use "local/{entry_id}"?
    – Ian Pitts
    Commented Jul 18, 2013 at 12:33
  • Update: I added {entry_id} as a tag in the cache breaking rules and have tested and verified this. PERFECT! Thanks a ton Aaron!
    – Ian Pitts
    Commented Jul 18, 2013 at 14:23
  • I tried using the {entry_id} as a tag, and found that the tags built up quite quickly on a large site. If you find the same and ever want to delete them, then this feature request might save a lot of clicks: devot-ee.com/add-ons/support/ce-cache/viewthread/9984 ;-)
    – Stephen
    Commented Jul 18, 2013 at 15:52
1

Complicated question, Ian, especially since you have Structure involved.

I think I'd want to talk with Aaron Waldron directly -- some basis below.

  • the primary ability of CE Cache is to break on change or addition/deletion action within a channel. You can then target what might be broken as a result.
  • you can of course break the entire channel. A tricky part here is what this may actually mean. CE Cache appears to break according to the apparent path -- template group/template. I am not sure if the original EE path isn't still available and used with Structure, but there are other implications.
  • The rules you can set for CE Cache appear I think only on the add-on module's Cache Breaking page for the individual channel involved. And that emphasizes that you can only condition a cache break on channel changes.
  • thus I think that to do something as you would like to do, it would be a non-trivial addition to CE Cache capabilities - both to trigger on path rather than channel, and then to identify at least a partial path per each such rule to break.

I'm thinking then that depending on what Structure's effects are, you may be just as well to break the channel/s holding all the items. You have the auto-rebuilding options at the top of the cache breaking page to get the full cache rebuilt in some sensible interval - see the notes for tradeoffs and times there.

I had a brief look at Template Morsels, but didn't spot anything more helpful there, and with those, I think you are required to do a lot of modifying of your template code, which is not needed in the default use of CE Cache, though it's fully capable of spot caching also.

Hope this view helps the thinking, anyway. I'd talk to Aaron...

2
  • I was thinking it might be possible to use a clever implementation of tags that represent combinations of URL segments to do this. Perhaps I need to continue that line of thought. Breaking the entire channel would cause slow performance for entirely unrelated sections of the site while the cache was being rebuilt which is not desired. Thanks for the thoughts!
    – Ian Pitts
    Commented Jul 12, 2013 at 12:16
  • 1
    Yes, tags attracted me too, but again, without ability to initiate breaks on a path rather than a channel, I think that road's not yet open. But all the more reason to see what Aaron may think. And Mark Croxton's definitely opening up a point. Is it only the nav you want to be refreshed? Then give or take how Structure arranges this, might be a good way to go, and there might be finer points on just what you do/don't cache. Testing performance should let give good clues. Best fortune, however you go on this... Commented Jul 12, 2013 at 16:46
0

How about escaping the secondary navigation so it's not cached at all?

     {exp:ce_cache:escape}
     Structure navigation here
     {/exp:ce_cache:escape}     
1
  • Hmm... that's an idea. I'll have a test to see how it affects performance. Is there a reason we can't cache break based on url segments? In the cache clearing interface it shows those segments so I'm thinking we could possibly break the cache using those same url components.
    – Ian Pitts
    Commented Jul 12, 2013 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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