Why would the {% cache %}
tag be storing a new cache every time the page loads (instead of just loading the existing cache)?
Unless I'm misunderstanding how caching works, the system should never record duplicate cache keys, correct?
Despite the data apparently getting cached, the page never feels like it's pulling from cache. Every page load feels long and sluggish.
UPDATE:
I've done some additional testing, and was able to get the caching to perform as expected. Here's what changed...
In my original version, I was caching a giant chunk of the template. This included the large database query (100+ records with 100+ fields), some Twig-side data manipulation, and the entire HTML portion of the template. Within the HTML, I am looping through those records and rendering a chunk of HTML for each.
In the new version, I am only caching the HTML loop. This is making a huge difference, bringing the page load time from ~15 seconds to ~1 second.
What I've found...
It appears that the offending line which was causing multiple cache keys to be generated is this one:
{% set entries = craft.entries.section('mySection').type('myType').limit(null).find %}
I still don't know why, and would appreciate an explanation if anyone knows!
cache
tag around that{% set entries %}
line, and that's basically my test case. If you'd like I can submit the whole thing to [email protected] (along with a DB export).