I have my css files placed under style library not in _Layouts folder. how to cache these style library assets?

Please help me


  • 2
    Caching happens automatically. Are you seeing a situation where they are not being cached, if so, please elaborate in your question
    – Dave Wise
    Oct 17, 2013 at 21:40

2 Answers 2


You can use query string for every new JS/CSS files like ?v=GUID to trick the browsers, which definitely will ensure new CSS/JS will be loaded every time you perform a new deploy. Otherwise, there is no clean solution to avoid browsers' behavior.

/Style Library/my_js_file.js?v=GUID
/Style Library/my_js_file.css?v=<current date>

Essentially all you have to do is make the browser think that its a new version of the file which is easily accomplished using a query string parameter.

For example, http://sharepoint/styles/mystyle.css could become http://sharepoint/styles/mystyle.css?version=1 and you would just update this link every time you update the CSS file.

If you want to do this more dynamically, its common practice to use the current date as the query string parameter value, but this will obviously require links to be generated using code, often times JavaScript, like the following:

var d = new Date();
var url = 'http://sharepoint/styles/mystyle.css?date=' + d.getTime());

You can then use the URL variable to set the link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.