Eduard Lebedyuk · Feb 10, 2017

How do I disable cache for static files in web application

I have a web application with html, css, js files (no ZEN/CSP).

Problem: after I update them on a server, Caché still servers old and cached version (browser Cache is disabled).

There is a manual cache purge in Gateway Settings, of course, but is there an automatic solution?

I'll be okay with disabling cache server-wide, but an application-wide solution would be better.

I don't want to host web app on a separate web server.

Here's my web app config:

0 1,726
Discussion (5)0
Log in or sign up to continue

Reading %CSP.StreamServer makes me think that I need to set "Set Files Timeout" to 0.

Testing that.

Correct, the gateway will not cached files that are not served from 'always and cached'. Of course if you served a static file when this was set and then unset this then the gateway will still have it in its cache. Also the timeout value applies both to the browser timeout period and the CSP gateway timeout period.

You can also remove items from the gateway cache using code (which we do automatically when you edit a static file in Studio):

Set registry = $System.CSP.GetGatewayRegistry()

Set sc=registry.RemoveFilesFromCaches(remove)

See the class %CSP.Mgr.GatewayRegistry for more details of this method.

Static files were edited outside of Studio.

Setting timeout to 0 and purging the cache once solved the problem.

I change the names of the files in order to do that, like this:

csp file:

<!DOCTYPE html>
<csp:include page="includes/libraries.csp"/>

inside the includes/libraries.csp file, rename the file as "jquery-1.11.3.min.js" instead of just use the file as "jquery.min.js" :

 <script src="jquery/jquery-1.11.3.min.js"></script> 

this in order to avoid the server to load the old file