My approach is using the “querystring changing” method to bypass caches (even in browser and proxy servers).
Since I’m using Master Pages I maintain the link to CSS as usual like but adding an ID (named here as cssStyleSheet):
<head runat="server">
<link id="cssStyleSheet" href="~/Styles/Default.css" rel="stylesheet" type="text/css" />
Then at code behind I implemented at Page_Load this line of code, adding a quesrystring like “?t=5343423424234”.
Protected Sub Page_Load(…)
If IsNothing(Application("CSSTicks")) = True Then
Application("CSSTicks") = DateTime.Now.Ticks
End If
cssStyleSheet.Attributes("href") = cssStyleSheet.Attributes("href") & "?t=" & Application("CSSTicks")
End Sub
Why is that?
At HTML code, some designer could change the CSS file as easy, no interfering at some “difficult” code.
Using an Application variable I avoid spending bandwidth from my servers and also from customer perspective (like using mobiles).
If new application is deployed, the Application variable is reset automatically and a “new” version of CSS if downloaded to browser (even through proxies).