Built-in CSS versioning

Posted by Community Admin on 05-Aug-2018 18:54

Built-in CSS versioning

All Replies

Posted by Community Admin on 04-Apr-2014 00:00

I have not seen any documentation on this, so I thought I should post information about the built-in CSS version query string in Sitefinity.

By default, when you add a css file to your theme, Sitefinity will add a query string with the version number such as style.css?v=60743210. This is very helpful for making sure that when you push updates your users immediately get your updated styles.

There is one important thing to know in order to get this to work. As far as I can tell, your theme must be in the ~/App_Data/Sitefinity/WebsiteTemplates/[YourFolder]/App_Themes/[YourTheme]/ folder, otherwise the query string will not be added. It does not work if your theme is in ~/App_Themes/[YourTheme]/

Posted by Community Admin on 08-Apr-2014 00:00

Hi Michael,

Thank you for sharing this information with the community.

Regards,
Sabrie Nedzhip
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 03-May-2016 00:00

Do we know what causes the version number to change? What triggers a new version number? 

Also, I've noticed that CSS files in the ~/App_Data/Sitefinity/WebsiteTemplates/[YourFolder]/App_Themes/[YourTheme]/Global folder do get the version number, but if you have files in deeper folders like ~/App_Data/Sitefinity/WebsiteTemplates/[YourFolder]/App_Themes/[YourTheme]/Frameworks/Telerik it doesn't get a version number. 

So the question is really, what are the exact rules around this versioning feature? 

Posted by Community Admin on 06-May-2016 00:00

Hey Jacques,

As also posted on SO (but just for completion here) the behavior is part of the ThemeController class inside Telerik.Sitefinity.dll and essentially checks for the file last write time-stamp  to include the cache busting version number.

string str = string.Concat(VirtualPathUtility.AppendTrailingSlash(theme.Path), "global/", fileInfo.Name);

The /global/ part of the folder structure is hard-coded so you'll have to work around it if you'd like to make it work for other folders.

This thread is closed