42 users online (1 members and 41 guests)  


  Results 1 to 13 of 13

Related

  1. prevent pop-up    Forum: HTML Forum
    Replies: 1
  2. Cached Page Problem    Forum: CSS Forum
    Replies: 0
  3. Replies: 0
  4. Replies: 0
  1. #1
    Dillon's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Location
    Cape Town, South Africa
    Posts
    7

    Question 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.

    ANY ideas most welcome

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi there.

    You could try adding no-cache headers to the asp page -

    Code:
    <% Response.CacheControl = "no-cache" %>
      <% Response.AddHeader "Pragma", "no-cache" %>
      <% Response.Expires = -1 %>
    Secondly, 48 hours is a long time for proxy or isp caching. I would say its your browser. Have you tried clicking refresh whilst holding down either Ctrl or shift, depending on your browser?
    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?

  3. #3
    Dillon's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Location
    Cape Town, South Africa
    Posts
    7
    Hey Dean

    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.

    Thanks again.

  4. #4
    cm1's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2003
    Posts
    2
    Hi,

    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!

    Thanks!

    cm1

  5. #5
    Dillon's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Location
    Cape Town, South Africa
    Posts
    7

    Unhappy 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.

    Cheers

  6. #6
    cm1's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2003
    Posts
    2
    Thank you! I am looking forward to your reply and will post myself if I come up with anything in the meantime.

    Thanks again.

    cm1

  7. #7
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,445

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    May or may not work, but try changing the link to an absolute instead of relative.

    Dave

  8. #8
    jafo's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    2
    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.

    /jaf

  9. #9
    jafo's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    2
    omg this was an old thread... :/

    didn't see all replies until I posted...strange

    /jaf

  10. #10
    Dillon's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2003
    Location
    Cape Town, South Africa
    Posts
    7

    Exclamation Still a problem...

    Hi jaf

    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

    cheers
    Dillon

  11. #11
    Khaledf's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2008
    Posts
    1

    Thumbs up Re: How to prevent CSS being cached by proxy

    Solution:
    This problem happens also to javascript files.
    to solve it I would suggest to randomize the call to the file from html

    notice that the following calls are similar:
    mystylesheet.css
    mystylesheet.css?32343


    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

  12. #12
    acgna's Avatar
    New User

    Status
    Offline
    Join Date
    May 2008
    Posts
    7

    Re: How to prevent CSS being cached by proxy

    I was having the same problem

  13. #13
    mistknight's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2009
    Posts
    1

    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...



Tags for this Thread