Stylesheet Updating

Travis Anstey asked on April 11, 2022 23:41

Is there a way to force a browser update of css included in a project stylesheet, similar to how you can force a resource file to get updated by including an arbitrary version in the query string for the resource? For example, we can add "&ver=1.0" to ensure that the updated custom_javascript.js file is overridden and the new file used to apply updated javascript in a page. https://domainsite.com/CMSPages/GetResource.ashx?scriptfile=~/CMSScripts/Custom/custom_javascript.js&ver=1.0

Pretty sure I came across the answer to this in the documentation and that clearing browser cache is the only way to get the updated styling to take effect, but I wanted to double-check. I believe another answer suggested that for more control, we can put basic site styling in the stylesheet and then include references to custom css as needed. Would this be the advisable route to accomplish what I was asking above regarding further control to override browser cache?

Recent Answers


Brenden Kehren answered on April 12, 2022 00:09

What development model and version are you using?

0 votesVote for this answer Mark as a Correct answer

Travis Anstey answered on April 12, 2022 15:19

We are using portal engine on 11 right now.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 15, 2022 14:14

What we have done in PE is to use the stylesheet GIUD at the end of the URL as a parameter. Something like this:

<link href="/CMSPages/GetResource.ashx?stylesheetname=SiteCodeName&vid={%GlobalObjects.CssStylesheets.SiteCodeName.StylesheetVersionGUID#%}" type="text/css" rel="stylesheet"/>

It works very well especially since it's tied to the version history of the stylesheet. For the JS files, since they don't have versioning or any history in the database, you're best just appending your own parameter whenever you change it.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.