+1-888-365-2779
Try Now
More in this section

Forums / Designing & Styling / Built-in CSS versioning

Built-in CSS versioning

4 posts, 0 answered
  1. mdub
    mdub avatar
    12 posts
    Registered:
    22 Aug 2012
    04 Apr 2014
    Link to this post

    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]/

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    09 Dec 2016
    08 Apr 2014
    Link to this post
    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
     
  3. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    03 May in reply to mdub
    Link to this post

    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? 

  4. Jochem Bökkers
    Jochem Bökkers avatar
    787 posts
    Registered:
    13 Aug 2007
    06 May in reply to Jacques
    Link to this post

    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.

4 posts, 0 answered