Issue
I have a single page application (angular-js) which is served through IIS. How do I prevent caching of HTML files? The solution needs to be achieved by changing content within either index.html or the web.config, as access to IIS through a management console is not possible.
Some options I am currently investigating are:
- web.config caching profiles - http://www.iis.net/configreference/system.webserver/caching
- web.config client cache - http://www.iis.net/configreference/system.webserver/staticcontent/clientcache
- meta tags - Using <meta> tags to turn off caching in all browsers?
IIS is version 7.5 with .NET framework 4
Solution
Adding the following into web.config
solution worked across Chrome, IE, Firefox, and Safari:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="index.html">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
</configuration>
This will ensure that the that Cache-Control
header is set to no-cache
when requesting index.html
.
Answered By - Andrew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.