Disable caching#77
Conversation
There was a problem hiding this comment.
Pull request overview
This PR attempts to address issue #75 (“Server won't run code”) by disabling HTTP caching for CodeWorld server responses, likely to prevent clients from using stale web assets after recent changes.
Changes:
- Import
setHeaderfromSnap.Core. - Add a
disableCachingSnap action that setsCache-Control. - Invoke
disableCachinginsitearound the main routing/static file handling.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I want to add here what It does not completely disable caching, but instead makes the client validate that its cached resource is still up to date by asking the server. If the server thinks it is up to date, then the cached version is reused, otherwise it is invalidated. |
I did read that on the MDN article. Are you suggesting changing the name of the |
|
No, I just want to document that fact if someone else reads this PR later. And I'm also typing up something to discuss on that point right now. |
|
I'm not really satisfied with this solution in principle, because it is not going to be a common (let's say daily) occurrence that static resources like JavaScript are not up to date. So this is going to add a lot of extra back and forth between client and server for mostly no reason, aside from invalidating caches right now. I read a bit on the topic and it seems a common solution to this kind of problem is using versioned resource names like That seems like a better fit for what we want to achieve, but I'm unsure if it is worth the effort of having to potentially change file names a lot in the future. I think it depends mostly on how abstracted the resources are handled in the Server code, i.e. how often their actual names show up there instead of using generalized functions like @nimec01 what do you think about this? Is that reasonable in light of how the server interacts with served files? |
Yes. This should really just be the quick and dirty fix.
The web client is really just basic HTML, CSS and JavaScript. Thus changing a filename would require us to also update all references to that file in the code. The way to go would be to use some kind of bundler that automatically does that for us. But I didn't want to try that yet. |
|
I'll open an issue concerning what we discussed here, but it is more important to make sure students don't encounter problems next week (see Slack conversation). |
This should fix #75