Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How long does browser cache (.js files) exist

ASP.NET 4.0

If I updated my .js file in a page, however it seems client's browser doesn't download the new .js file (due to browser cache?). What factors could affect the old .js file remain on client's PC? Is there any way to force client to download new .js file?

EDIT: I still got another question -- How long does the browser keep the .js cache? Is it controlled on client browser setting?

like image 891
Stan Avatar asked Dec 04 '22 22:12

Stan


2 Answers

well, your production file is not suposed to chage frequently, try to put a version on your file name, like jquery, a new version generates a file with new name like that:

/myfile.1.0.0.js

to:

/myfile.1.0.1.js
like image 163
Flavio CF Oliveira Avatar answered Dec 09 '22 15:12

Flavio CF Oliveira


A simple way to get the browser to download a file again is to add a querystring onto the url

/myfile.js?v=1
like image 20
Geoff Appleford Avatar answered Dec 09 '22 15:12

Geoff Appleford