SuperSans SuperSans - 6 months ago 10
Javascript Question

Updated javascript files not being distributed by the server for several minutes after updating them

I'm currently on a Bluehost shared hosting service, and for whatever reason my javascript files, upon change in the server's directories, will still be served as their old version until 10+ minutes passes. This is making development extremely slow and difficult. Is there any reason the server is doing this, and is there a way to disable whatever sort of caching is going on?

daf daf

First, check that it isn't your browser caching - in Chrome developer tools, you can disable caching. Perhaps also try a private window. If that still fails, the hosting service may have caching (would make sense for their business).

Cheap hack though - add a timestamp value as a query parameter for all script tags, eg:

<script type="text/javascript" src="script.js?t=12345" /><script>

how you accomplish this is up to what sever-side code you're using. The changed URL should defeat caching and won't affect the script.