We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Embedded template caching seems different between desktop and mobile

Development and Programming

Jason Sibre's avatar
Jason Sibre
4 posts
11 months ago
Jason Sibre's avatar Jason Sibre

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

       
Tom Jaeger's avatar
Tom Jaeger
449 posts
11 months ago
Tom Jaeger's avatar Tom Jaeger

Thanks for posting all of this.. It’s interesting.

We haven’t really seen reports like this before. Traditionally cache is based on URL, and shouldn’t changed based on device (unless the site is setup for different templates to render for mobile etc.)

       
lunahart63's avatar
lunahart63
1 posts
one month ago
lunahart63's avatar lunahart63

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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.