Sharepoint CSS/JS Caching problem

One easy way to resolve CSS / Javascript caching problem in sharepoint when caching is enabled is here,if your current links to your css and js files look like this:

<link rel=“stylesheet” type=“text/css” href=“/_LAYOUTS/yoursolution/yourstyles.css” />
<script type=“text/javascript” src=“/_LAYOUTS/yoursolution/yourscript.js” ></script>

Generate a random number, or use a utc date time stamp and append it as a querystring like so:

<link rel=“stylesheet” type=“text/css” href=“/_LAYOUTS/yoursolution/yourstyles.css?r=123654” />
<script type=“text/javascript” src=“/_LAYOUTS/yoursolution/yourscript.js?r=123654” ></script>

This will make sure the next time when the JS is loaded it ll load a new version

Leave a Reply

Your email address will not be published. Required fields are marked *