Jump to content
GreenSock

iDad5

Strange Caching Behaviour Related to ScrollTrigger

Recommended Posts

Some time ago I had a weird problem with a script seemingly being stuck at an old  state and all tries to clear the cache didn't work.

See End of this topic:


Only when I resized the browser window the new script did work. I more or less forgot about it and thought that it might have had to do with CodePen, the script in question being complex and all of it begin a one time occurrence....

 

But today it happened again. I was investigating why my local example was behaving differently from  the CodePen one I created for seeking help here. I was clearing caches, reloading etc. but it still behaved not as expected. Until I resized the browser-window...

It was Chrome on Windows this time, last time it was Firefox. 

Am I'm getting crazy or had somebody else similar experiences? 

Link to comment
Share on other sites

I have no idea how resizing could possibly fix a caching issue. It doesn't seem possible unless you have some extension that is interfering with it somehow. When I see weird browser behavior, I like to check it out in a new incognito window as a sanity check.

 

 

Link to comment
Share on other sites

I also have no idea how this could happen. As I have written in the thread where the issue occurred first, I did even restart the whole system but the browser window opened with the same size as before….

 

I also have no way of reproducing the issue, the only commonality I could see was the use of ScrollTrigger. 
 

This time I only reloaded several times and cleared the cash once, but only after resizing (on the first reload) the expected behavior occurred. I know it sounds (and is crazy) and I cannot imagine a logical/technical explanation that would make sense, that’s why I posted it. 

Link to comment
Share on other sites

I've never heard of anything like that. I'm relatively confident it's not a ScrollTrigger thing, but if you can give us a minimal demo that clearly shows the issue, we'd love to take a peek. 

 

The only thing I can think of is maybe you were dynamically loading things that affected the layout AFTER the onload event fired for the page, thus the ScrollTrigger start/end values became inaccurate (until you resized which forces a ScrollTrigger.refresh() and corrects them). 

 

So make sure you're creating your ScrollTriggers AFTER the layout is settled -OR- you can just call ScrollTrigger.refresh() after you're confident the layout is done changing. 

  • Thanks 1
Link to comment
Share on other sites

I'm a bit deeper into investigating my unnatural experience...
First, I'd like to apologize for the 'related to ScrollTrigger' part in the headline. I actually never thought that it was a ScrollTrigger bug, I just meant that the phenomenon occurred to me while working with ScrollTrigger.  (Which for me often means complex animations often large images, etc.)

I have experienced similar or related behaviour (as described above) more often these days, and I'm guessing now that it might be connected to the browser's debuggers. I have the (detached) debug window open and caching disabled. So every reload should give me a completely fresh start.

And it does - mostly. One thing is, if you inspect an element with the dev tools that same element will be highlighted again even after reload, and even after changes to the page as long as the page structure does not change too much. Therefore if seems logical to assume that the developer-tools  store at least some information about the page even beyond a reload.

The only way I can explain what I'm experiencing sometimes is, that the dev-tools keep some information cached, probably for performance reasons. A resize should trigger a repaint and therefore might clear some 'stuck-stuff'. Sounds far fetched I know, but it's (for now) the only somewhat reasonable explanation I can think of. 

My multi display setup with all different screen sizes, pixel-density and resolution might add to the situation, at least I suspect as much. I don't understand the details of hardware accelerated graphics and all the performance optimisations of modern browsers, but my guess is that it might play into that.

 

 

 

 

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×