user2252219 user2252219 - 1 month ago 12
CSS Question

Dreamweaver keeps uploading old css when I updated it with a new one

So I changed my css in Dreamweaver and went to sync it with my remote server. However, it isn't changing the style sheet on the remote server. It's just not updating. I've tried wiping my whole site and reuploading it all over again but nothing. It keeps defaulting back to my old style sheet. I'm completely lost at what to do. When I open the site just locally, all my changes are there.

The site: http://imdarrien.com/#

ex: I changed

#profile { text-align: center; margin-top: 5px;}
to
#profile { position:fixed; left:0; right:0;}
. But the site still shows no changes to position.

Tim Tim
Answer

While I can't be certain, I presume that this is actually a problem with caching. Browsers cache content as a way of loading pages faster, so you need to change the name of the file you're updating to see the changes reflected on your server. Try appending a query string to the end of the file name.

Example change:

<link rel="stylesheet" href="style.css">

to

<link rel="stylesheet" href="style.css?v=2">

Most browsers will actually see the query string at the end of the file name and think of the file as a completely different one, breaking the cache.

This CSS Tricks article further provides strategies for "cache busting"

Since I use PHP, my favorite method of cache busting is to append the query string of ?v=<?php echo time() ?>, which will always provide a unique file name. Of course, when you move to production, you should keep the file name constant (unless you make changes), to allow caching to occur; cached websites load much faster.