wederer
wederer

Reputation: 570

How does cache busting work on the index.html?

The main two ways to cache bust are:

  1. hash inside filename: styles.hash123.css
  2. hash inside path: styles.css?v=version1.23

I understand the reason and mechanisms behind this.

However what I do not understand is how to cache bust the index.html of a website, for example a SPA. The browser cache could keep the index.html of the SPA for a long time and thus the css/js files would never get cache busted.

Is the index.html handled as a special case by browsers or could the described behaviour happen?

Upvotes: 4

Views: 4763

Answers (1)

nemo
nemo

Reputation: 364

Add to your HTML head:

<meta http-equiv="Cache-Control" content="max-age=0, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0" />

Upvotes: 6

Related Questions