How to update a web app without suffering cached CSS issues?


Tags: css,web-deployment

Problem :

Say I've got a web app. I add some features to it, and those features require additions to some existing CSS files on my web server. I deploy my new features and CSS additions to my server, and they work great. Users visiting the site will probably have cached CSS in their browser, though, which means the new features will look broken/weird until either they manually refresh the page or their cache expires. The problem might be even worse if there's a cache server between my server and the user, in which case even a manual refresh won't help (I don't think).

Is there a common way to avoid this?

EDIT: I'm running on ASP.NET 4.0.



Solution :

You can add an arbitrary name value pair to the end of your css request and it will act as if it's not cached. For instance:

<link media="all" href="myhomepage.css?sid=1" type="text/css" rel="stylesheet">

When you make a change change the sid value.


    CSS Howto..

    Dropdown Menu doesn't show all links and can't change css social media icons color

    How to exclude styles for a some specific elements using css?

    How to center text inside a div element? [duplicate]

    How to change css image via php depending on weekday

    How to css this little button next to