Click here to Skip to main content
15,798,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am facing one issue , When I deploy my code changes (,c#) in UAT server. Every .aspx file takes the latest version of javascript file and it works correctly but when I deploy my code in production server then .aspx sometimes take cached version of javascript file which cause no new changes is seen to end user.

Some end user doesn't shutdown their desktop so they face the issue.

I want whenever user visit any page (first time /second time), page should take the latest version of javascript.

I am facing this issue in Internet Explorer 11.0.
In Internet Explorer, general setting of Temperort internet files i.e.
Check for newer version of cache version,Everytime I visit webpage that is not feasible because website is used by many users.

If you have any other solution please let me know.

What I have tried:

<script src="Javascript./Myjavascript.js?session="+SessionID type="text/javascript"></script>

in aspx file


I tried above two solution but still end user face cache issue.
Updated 12-Sep-16 5:42am

<script src="Javascript./Myjavascript.js?session="+SessionID type="text/javascript"></script>

Assuming SessionID is the session ID, you are on the right tracks but there is a problem with your implementation. If you update the js file in the middle of someone's session then their id does not change so they don't see the new version, also session IDs get re-used so they can keep their session id longer than you might think they do.

Rather than use the session id just use a simply version number that you increment each time you release

<script src="Javascript./Myjavascript.js?ver=1" type="text/javascript"></script>

The next time you update the js file change it to ver=2 and so on.
Share this answer
RAHUL(10217975) 12-Sep-16 10:34am    
So, according to your solution when I deploy aspx file I should increment ver=1 by 1 ?
I guess that won't be feasible from developer end to remember every time I deploy.
David_Wimbley 12-Sep-16 10:52am    
Don't just get held up and reject it because you think the work is manual and not possible to remember to do.

There are plenty of different automated ways of doing what was suggested...sometimes solutions aren't one size fits all, you've got to do a little bit of work to make it exactly what you want.

You could append a GUID, a date, anything to do this. If you had a build server you could implement an automated task in your build server.
RAHUL(10217975) 5-Oct-16 10:14am    
sorry for late reply,
But cache issue doesnt occur in UAT and QA server, is there any server setting i m missing ??
F-ES Sitecore 12-Sep-16 11:22am    
You could automate it in some way, such as holding the latest version in a database, but those methods don't perform as well. You could also use something like the minification library you get with, that should solve this issue for you too as your js file will have a checksum attached that solves this problem.
I do not think there is a perfect answer. We have some places where we tack on JavaScript
new Date().getTime()
to the end or our urls so that IE will think it is a page that has not been viewed before but we still have cache issues. It usually works but not all the time.

The best option is to remind your users to clear their cache.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900