Skip to content

Serious caching error with p5 Editor #1234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
everythingability opened this issue Jan 9, 2020 · 14 comments · Fixed by #1483
Closed

Serious caching error with p5 Editor #1234

everythingability opened this issue Jan 9, 2020 · 14 comments · Fixed by #1483

Comments

@everythingability
Copy link

I can be working on a sketch, and open the Present or Full view and it doesn't reflect the changes I've made.

I clear cache and reload... same thing...

THEN I open a new Chrome window and open the sketch and it's a PREVIOUS version of the sketch... Often if I save at that point I've then lost my work to an earlier version.

This has happened more than once... don't know if it's the browser or the p5 Editor site...

@welcome
Copy link

welcome bot commented Jan 9, 2020

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

@catarak
Copy link
Member

catarak commented Jan 9, 2020

Thanks for reporting! I have noticed this but I'm unsure how to fix it. Open to all ideas and suggestions!

@everythingability
Copy link
Author

I have tried adding ?a=123 to the end of a URL but that only works once I've gone to the source and clicked the URLs in that (and appended a bit different)...

The REAL PROBLEM is when you return to an old tab, reload, edit and save.... argh!

@catarak
Copy link
Member

catarak commented Jan 9, 2020

If you do a hard refresh (shift + command/control + r), it should clear the cache! Not the best solution, but it's something.

@everythingability
Copy link
Author

That doesn't work. Trust me.

@catarak
Copy link
Member

catarak commented Jan 13, 2020

got it. then I guess it's caching from the CDN. i guess possible solutions are:

  • generate a unique link to the preview
  • generate unique links to the included files (js, css, etc).
  • ??? other methods to clear the cache

@ashu8912
Copy link
Contributor

ashu8912 commented Jan 14, 2020

Ok So This Problem is there only till the user has not saved the sketch and has moved to a new tab one possible soultion could also be to store the current sketch that is in editing mode in localStorage(or a serviceworker) that could preserve the sketch code between tab switchs
This would also take a very less amount of local storage space as we would be storing only the current sketch details in there.

@ashu8912
Copy link
Contributor

There are 2 problems here
1.The Code is not cached when in editing mode thus opening the unsaved code in new tab and than
opening the code in new tab doesn't depict the recent changes this is because our editing in the code editor is not cached.
2.The Second Issue is browser caching.For Our Preview Similar urls are generated but each url even
Though its the same doesn't depict the recent made changes on the preview

@catarak
Copy link
Member

catarak commented Jan 28, 2020

This issue is focused on the browser caching issue. I'm going to open a new issue about updating the sketch in a different tab!

@wetmore
Copy link

wetmore commented Jun 24, 2020

Not sure if there is a better issue to add this on to, but when I was writing a sketch using a webworker using a file worker.js, any edits to worker.js wouldn't be reflected in the cache. Edits to sketch.js were updated fine. Whenever I ran the sketch, a stale version of worker.js would be used. As a workaround I had to duplicate the sketch to get a new ID for it in order to get the latest version of my worker.js file.

I wasn't loading worker.js in index.html. I tried that but it didn't help.

@catarak
Copy link
Member

catarak commented Jun 29, 2020

@wetmore I think you're in the right place! Thanks for the additional info.

@catarak
Copy link
Member

catarak commented Jun 29, 2020

I think the solution here is to add a header in the response from the server. Specifically, I was looking at how Glitch.com handles this. Glitch adds the header cache-control: public, max-age=0. I'm going to try this out!

catarak added a commit that referenced this issue Jun 29, 2020
[#1234] Add header to clear cache for present view
@catarak
Copy link
Member

catarak commented Jun 29, 2020

It worked 😄 This will be fixed for the next release.

@dhowe
Copy link

dhowe commented Dec 1, 2021

Has this made it into the current editor? I'm still seeing this problem - makes it virtually impossible to use web-workers in the editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants