Hi,
(I’m on EE 7.5.7 - just updated a few days ago.)
I have a situation where I have an embedded template to render a ‘preview’ link/tile to a news story that is used on multiple pages (four). So, no matter which of those four pages a user is viewing (which differ primarily in which subset of channel entries they’ll present), the same embeddable template is responsible for rendering the clickable ‘tile’ that represents that story.
The way the embedded template works is that all the values it needs to render a tile are passed in as embed variables, which are then referred to using the “embed:variable_name” notation. It seems to work fine, and I don’t have any noticeable performance issues, and I’ve been able to remove a lot of duplicated code by using the embedded template approach.
However… Later, while conducting browser testing, I noticed that on mobile, sometimes I got the same story tile repeated over and over on the page. Refreshing the page seemed to restore the view to the correct sorting of the stories. I did a bit of debugging (outputting extra info from the parent page) to confirm that the Entries tag was properly looping over the correct stories, but that the output of the embed was being repeated. Seemed like some kind of template caching issue.
I did some reading about template caching, and I didn’t find anything that definitively explained to me just how caching is meant to work with embedded templates. I would assume that if the variable are the same, it might use results previously cached for those variables, but if they were different, they would not. I.e., it might be reasonable for the caching mechanism to assume the template had deterministic behavior, and cache accordingly.
Anyway, I updated the settings for that template to disable caching, and now it’s working fine. So, there’s no problem…
Except that I’m still confused; why was it only sometimes caching, if I was on mobile, and never caching if I was on a Desktop? I think there may be a bug lurking, or that there’s some configuration that affects this that I’m not aware of.
Does anyone know? Has anyone else seen this behavior?
I’ll also mention, perhaps a red herring: At one point, before I noticed one story repeating over and over, I was seeing a mix of stories, “shuffled”; the sort order was jumping around when I refreshed. I assumed my sort key wasn’t sufficient, and I addressed that by switching the channel:entries tag’s order_by from “date” to “date|entry_id”. I really don’t think this has anything to do with the issue above, but I mention it in case it’s a clue to someone. I never noticed this behavior until I started testing on mobile, but I was able to duplicate it on desktop. I think it just showed up more often on mobile. However, once I solved the “shuffling”, I noticed the problem of repeating stories (first noticed while testing the ‘shuffling’ issue) hadn’t gone away.
Thanks
Edit: Fixed italics vs bold
Many levels feel like cosmic dance orbit beats choreography. Planets move in sync with the music. Players feel immersed in the rhythm as they tap. Success feels musical rather than mechanical. The audio-visual connection drives engagement.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.