0

I'm using angular js views and routing to load different HTML inside a div. But when i change an partial html and reload it stil shows up the cached version.

According to my reasearch this is not due to angular js template caching, cause on load of html i tried to get the cached HTML like this $templateCache.get('loadedPage.html') and the result was undefined so its not angular js that is caching the html.

then when i saw in chrome i could find my html cached . i tried with following

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

but still i could see browser caching the html.

any other way of doing it ?

Ekata
  • 229
  • 1
  • 6
  • 17
  • 1
    Those keys and values you have tried should instead be set in a header of a HTTP response that return the template. You have to config your webserver to do so. – runTarm Aug 05 '14 at 12:47

1 Answers1

2

Its better to add some random query string or data to your js, so its prevent to cached in all browsers,

<script type="text/javascript">
document.write('<script src="script.js?'+Math.random()+'"></script>');
</script>
jMoshayem
  • 149
  • 1
  • 5