If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to prevent CSS being cached by proxy

Hi Guys,
Heres an iffy problem I've been having, and maybe someone has a solution out there.

I'm using Dreamweaver Ultradev to create an html+asp+css website. Once the site is structurally done, a few non-technical editors will be handling the daily updates and maintenance.

The problem starts when I upload an asp page with a css stylesheet as an external link. Somewhere between my PC and my host, (most probably my ISP), this CSS style is being cached by a proxy. Which works fine.... until I edit the css stylesheet. After editing, I still get served up the old stylesheet. Since the asp page is making calls to styles that are not present in the "old" css sheet, the layout is severely broken.

I'm sure the proxy will update its version of the style sheet eventually (its been 48 hours now and I'm still waiting!), but its not good enough.... I forsee many changes to those stylesheets as we go along.... which brings me finally to the question:

Is there any way (code to add?) to a stylesheet, that will prevent it from being cached by a proxy and/or browser?

I thought I had a solution today. At the top of each asp page, is an include file. So I banged in the html header for the style sheet link into a call statement. Each time the ASP page is loaded, it calls a sub from the include file, which pops in the ref to the stylesheet, which I rename everytime I edit. (eg. from home01.css to home02.css)
Since the name is always changed, I can prevent it from being cached, and I can change the "stylesheet call link" from one include file for the entire site.
This nifty idea fell apart when i realised that since the style sheet is now not present in the actual ASP page (just the ASP call function), dreamweaver wont make the list of styles (and layout) available to the editors... and I need them to be able to choose line spacings, fonts etc from that handy drop down list. So bang goes that idea.

Any ideas on how to resolve this? Ideally, I'm hoping someone will say: Hey There, just bang this code: "blah blah blah" into the top of your stylesheet and it will expire after x hours, or something along those lines. Is this even possible? Searches on the net have lead me to plenty of java solutions, but... not really keen on messing with java on this project.

As a worst case scenario, I can create a code snippet for the line with the css link, and then just update that... but what a mess that will be.

I've tested it on several computers (that had not accessed the page before), so I know its not the browser.

I then used a different computer to log on to a different ISP, and access the page... it worked perfectly.
So the only weak point it seems is the ISP, that is caching the page locally. I think they do take drastic measures to ease international bandwidth pressure, as South Africa's international b/w is a joke, and the site is based in the UK. So the caching time might be quite long.

Still getting there with Stylesheet Refresh problem

Hey CM1,
sorry mate, but I havent had much luck yet. I had to prioritise other development projects I'm working on, so I put this on the back burner for now.

I did try Dean's "cache control" solution, and that came in handy for several of my other pages (thanks Dean), but it didnt work with the stylesheets. How long has it been, about a month now?... and I'm STILL getting served up that original stylesheet. I'm convinced it is the South African backbone provider, Telkom, (single provider, monopoly - need I say more), who is caching certain pages and not refreshing them.

I tested this theory by uploading a redirect page on a website. (redirect from one website to another). Opened it in the browser, it worked fine. Then I FTP'ed in, and deleted the redirect page, and put up a replacement hard HTML page. Guess what.... 3 weeks later, when I log in to Website 1, i still get redirected to website 2, as if that redirect page is still there. Its not there, I deleted it. It has an index.html, index.htm, default.asp... etc etc. Unbelievable. (Btw, both website servers are in the UK, so I think Telkom is caching international pages for months at a time to ease their international bandwidth carrier costs.)

At any rate, as soon as I have some time (towards this weekend) I intend to tackle this (and the ISP) and solve this problem once and for all.
Will post any progress on this thread.

Still a problem...

Thanks for the reply. It is an old post, yes, but still very much a problem (for me anyway!)

I've exhausted just about every option and no luck.

I just checked the FTP server timestamps for the relevant files - all a-ok. So it cant be that (unless theres something else I'm missing?)

And unfortunately, its not my own server. So i can't modify the actual file expiry data.

Heres the crunch tho... after changing and uploading a new CSS file, 4 months later, in South Africa, I am still getting the OLD non-existant CSS file (unless I change the CSS link and actual CSS file name). Nothing knew there.

BUT... I've asked a friend in the UK to check the site for me, and guess what... he gets served up the new correct CSS file. I did a quick test, changed the file a third time, and voila... he gets the correct NEW file each time, even immediately after I change it.

The ONLY thing I can think of then is that our major bandwidth providers in SA are using some ruleset on their caches when accessing international sites. (My site is hosted on a UK based server, even tho I'm in SA)

So for the time being... I give up. I'll just have to change the filename and links every time I modify the CSS contents.

Re: How to prevent CSS being cached by proxy

Re: How to prevent CSS being cached by proxy

Well, time to kill this thread once and for all.

Like a response header may carry a pragma: no-cache header, a request could also contain it. In other words, you could, in your request, tell the ISP you don't want their cached version, promoting a cache refresh. In linux, just do this:

wget --no-cache http://www.example.com/whatever.css

The ISP cache, once it receives this request, will throw their cached version and retrieve the latest one from the server (I heard some cache severs ignore this, haven't met any of them though! And I sure don't want to!). And yes, this simple call should affect ALL users who sit behind that stubborn caching proxy, which is generally all users with the same ISP.

How to do it on windows? Well, I have no idea. But it generally boils down to somehow injecting that pragma:no-cache into the request header, probably some firefox extension can do that (tamper data?), this is generally tested and semi-guaranteed. But do make sure before you reply saying this doesn't work you flush your browser's cache completely! Any feedback welcome...