0

I have a site with some poorly written code which creates the desired left hand menu from a structure with several hundred entries. Page generation on the server for uncached requests takes 3-5 seconds. Longer term I know I need to fix the code, but short term I have cached the section of code using {% cache %} and this works really well - until the cache is cleared.

Now I have tried Cache Warmer and on running the script I get the presumable success message "All urls are all warmed up". However all caches are clearly not warmed up when I test the pages - the first load is still slow (and it isn't local caching that helps). There are some numbers in the Cache Warmer plugin configuration screen that suggest there may be a maximum. Furthermore I have certain pages that are not based on their own entries e.g. A site map which runs straight off its own template. This page is particularly slow until it has been run once. So I am not entirely sure how Cache Warmer works and what I need to do to ensure that it warms the entire cache.

I am not using anything else. Varnish seems like a solution but for me its implementation might be a bit too complex (I don't have full server access and I am not very skilled on the server end).

1 Answer 1

2

Varnish is sometimes used to paint over poorly written code. It's not horrible to get it up and running, but it seems to me that in this case, it might just be easier to fix the poorly written code.

I believe that what cache warmer does is it pings all of the URLs to get the caches to regenerate... but that just triggers the cache rebuilding process, which isn't instantaneous with Craft CMS. Did you try waiting a little bit?

Does the data in the large structure change that often? Something else you could consider too is putting the left menu in a its own template that you cache and load via AJAX so that the rest of the page isn't waiting for it.

2
  • Thanks @khalwat. No, I didn't wait too long for the cache building process, probably only a few minutes - I thought it might be happening in the background. You other comments make sense so I will progress things in that direction. Commented Nov 23, 2015 at 23:40
  • If your menu doesn't change across pages, {%cache globally %} is a good option, otherwise each url has to grab that menu. Commented Nov 25, 2015 at 15:59

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.