Results 1 to 13 of 13
prevent pop-up Forum: HTML ForumReplies: 1
Cached Page Problem Forum: CSS ForumReplies: 0
Any other Web servers out there other then Tnt Proxy? Forum: Web Hosting ForumReplies: 0
Any other Web servers out there other then Tnt Proxy? Forum: Internet ServicesReplies: 0
11-04-2003, 07:53 PM #1
How to prevent CSS being cached by proxy
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.
ANY ideas most welcome
11-05-2003, 04:07 AM #2
You could try adding no-cache headers to the asp page -
<% Response.CacheControl = "no-cache" %> <% Response.AddHeader "Pragma", "no-cache" %> <% Response.Expires = -1 %>If one of our members helps you, please click the icon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
11-05-2003, 09:20 AM #3
Thanks, will try the no cache headers and see if that works.
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.
Will post a reply here if the no cache header deal works.
12-01-2003, 08:01 AM #4
I am having the same exact problem with my CSS being cached. Did you figure out a way around this besides for renaming your CSS after each time you make a change?
I would greatly appreciate a resposne to this!
12-07-2003, 07:44 PM #5
Still getting there with Stylesheet Refresh problem
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.
12-08-2003, 08:55 AM #6
Thank you! I am looking forward to your reply and will post myself if I come up with anything in the meantime.
12-08-2003, 06:33 PM #7
May or may not work, but try changing the link to an absolute instead of relative.
03-24-2004, 11:33 AM #8
Could it just a timestamp problem with the updated file not having its timestamp updated correctly?
This could be ftp related...
If it's your own server, you can explicitly set expiry on individual files and directories via your webserver.
03-24-2004, 11:36 AM #9
omg this was an old thread... :/
didn't see all replies until I posted...strange
03-24-2004, 12:22 PM #10
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.
But thanks for the good suggestions Jaf and everyone else
01-27-2008, 10:57 AM #11
Re: How to prevent CSS being cached by proxy
to solve it I would suggest to randomize the call to the file from html
notice that the following calls are similar:
Got the idea?
you can use a random number in your php or asp file or just add a random number to your html page manually.
This way you can trick proxies that it is a new file and luckily the proxy will fetch a new copy of your file.
This should make your life easier
best of luck
05-05-2008, 11:17 AM #12
Re: How to prevent CSS being cached by proxy
I was having the same problem
02-15-2009, 05:39 PM #13
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...