Force Refreshing of Cache

Is there a way to make a site automatically force you to clear the sites cache? I am using the site for my class website and when I add something to the site the students don’t see it unless they refresh their cache. Is there a way to have the site force you to refresh when it loads?

Thanks much,


When exporting a Tumult Hype document, a number is added to the end of the document’s JS file:

<div id="index_hype_container" style="margin:auto;position:relative;width:600px;height:400px;overflow:hidden;" aria-live="polite"> 
<script type="text/javascript" charset="utf-8" src="index.hyperesources/index_hype_generated_script.js?4036"></script>

(The number 4036, for this example, which is almost the last character in the last line). This is a query string which browsers should understand: it means ‘don’t cache this JS file’.

If that’s in place it should be reloading each time someone visits. If that’s not the case can you share a document? A more forceful way to reload is to change the actual name of your document when you export.

I cannot get my site to not used cached images on safari mobile. Is there a way to flush out all the cache for users and make everyone going starting now get everything fresh? I changed so many images.

Yes, you can modify the URL using …

Hype Events: HypeResourceLoad

This event fires each time Hype resolves a URL name when preparing resources for display or while preloading resources.

1 Like

Adding on: you could potentially use a trick where it puts a random value as part of a query for the resource URL with the HypeResourceLoad technique. So if it gave imageName.png you could replace it with imageName.png?2343 (where 2343 gets randomly generated each load).

However, I wouldn't generally recommend this approach - browsers cache specifically for users to have better performance (and reduce server load).

Browser caching policy is usually determined by server directives. I would recommend looking into your server configuration to make sure that it is configured how you want.

One last thing to keep in mind: if you use the "create offline application cache" in the Document Inspector then you are explicitly telling the browser to be very aggressive in caching. I only recommend this setting when development is 100% done and you are developing an application which must be run offline.

And to add further to what @jonathan said you could just consider the string you add. A random number on each callback would be breaking all caching all the time and specially for end users this is probably mostly not desirable. The problem you want to solve is breaking cache in updates you as a developer make. I could think of a hard-coded version number you add in the event. You would then update the number and it breaks cache on the next deployment.

Update: Here is an untested example (Head HTML)

function HypeResourceLoad(hypeDocument, element, event) {
	return event.url+'?v1.0.0';

if("HYPE_eventListeners" in window === false) { window.HYPE_eventListeners = Array(); }
window.HYPE_eventListeners.push({"type":"HypeResourceLoad", "callback": HypeResourceLoad});

1 Like