I have a SharePoint 2013 Server in a test environment at my customer. It is filtered through a cache instance called Net Scaler, which does a good job delivering the same file to different clients. The problem is that it doesn't check if the file is new - it just pushes out what it got.
Adding a css-variable such as styles.css?ver=1000
solves the problem, and Net Scaler considers this as a new file. However, I'm having trouble making this unique on each page request.
Since this is SharePoint 2013, I'm not allowed to edit code behind and is limited to the .master file. I've tried different markups, but nothing that works the way I expect it.
This is my attempt so far, but it doesn't work as expected.
<SharePoint:CssRegistration
name="/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=
<%= DateTime.Now.ToString() %>" runat="server" after="SharepointCssFile" />
<!-- or -->
<link rel="stylesheet" type="text/css"
href="/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=
<%= DateTime.Now.ToString() %>" />
I even tried loading the css-file using inline JavaScript from this post How to load up CSS files using Javascript?:
<script type="text/javascript">
//<![CDATA[
var $ = document; // shortcut
var timestamp = Date.now();
var cssId = '/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=' + timestamp;
// you could encode the css path itself to generate id..
if (!$.getElementById(cssId))
{
var head = $.getElementsByTagName('head')[0];
var link = $.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = '/_catalogs/masterpage/Customer/Style/ResponsiveMaster.css?ver=' + timestamp;
link.media = 'all';
head.appendChild(link);
}
//]]>
</script>
But no luck there either.