Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

Forcing a Hard Refresh of cached website - in code?

Hi

Is there anyway (in code) to force a complete refresh of a website?

in a browser, I usually use ctrl F5
However, I need to the code to handle it on demand

Is this possible?

the idea is to write a cookie with the Version ID, and if the Version on the login page is different to that in the cookie then it must get a fresh copy and not use the cache

I know you can use Meta tags for No-cache etc, but would welcome some more insight

a possibility is to append the HTML with the no-cache meta tag (using asp.net) if the version ID's are different
but i'm not sure if its cross browser compliant etc

advice appreciated
ASKER CERTIFIED SOLUTION
Avatar of Edwin Hoffer
Edwin Hoffer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of websss

ASKER

Hi Edwin

Very interesting point about the ?v=1 on the CSS file
Does this also work on the Javascript files too?
Hello Websss,

You don't need to add any version in JS files.

Best Regards
Avatar of websss

ASKER

Really?
How would I stop the js file from caching using 2nd method ?
Ohh, sorry but if you want to prevent js file from caching then you have to use:

<script src="js.js?v=1"></script>

Open in new window


this will prevent from caching.
Avatar of websss

ASKER

great answer!