thehunterbat
thehunterbat

Reputation: 51

How To Force Reload Cached HTML Files

I have a simple website with css and html, everytime I upload new content it takes days to refresh. Is there a line of code that forces the browser to reload my code? I have a pdf link which changes week to week. I don't know if to force the entire code or just force the pdf link. Thanks

Upvotes: 3

Views: 10381

Answers (3)

Matin B.
Matin B.

Reputation: 405

Please check the following link: How do we control web page caching, across all browsers?

There are different ways to do that:

If you want to use a htaccess file, add the following line to it:

<IfModule mod_headers.c>
  Header set Cache-Control "no-cache, no-store, must-revalidate"
  Header set Pragma "no-cache"
  Header set Expires 0
</IfModule>

And if you want to just do that in the main html file, add the following to it within the head tag:

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

I hope my answer helps you.

Upvotes: 2

Manu G
Manu G

Reputation: 173

Use CTRL + SHIFT + R to reload

What chrome does is, when you load the page, it loads the external scripts. The first time you load the scripts, it caches it, so that it won't have to load it every single time. To clear the cache, use CTRL SHIFT R

Check this out: Clear the cache in JavaScript

Upvotes: 1

Or Assayag
Or Assayag

Reputation: 6346

You can add parameters to your static files, like:

<script src="your-source-here.js?v=34535" />

Same goes for other files.

For more advanced solutions: How to force the browser to reload cached CSS and JavaScript files

Upvotes: 1

Related Questions