SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: No-Cache Tag

  1. #1
    SitePoint Addict trinity0159's Avatar
    Join Date
    Jul 2002
    Location
    California
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question No-Cache Tag

    I have a website that is constantly being updated and alot users email me and complain they don't see the changes and I tell them to refresh and of course they see the changes. I am thinking about using "<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> " and was wondering if people could give some advice on it.

    Is it compatible with IE, FF, etc...?

    What are the drawbacks if I put this in every single page in my website?

    Is there other solutions?

    Thanks!

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use the tag the search engines will honor it, meaning that your pages will not be cached in their indexes.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTTP equivalents in <meta> tags are a poor workaround (although acceptable if you have no choice). It's much better to tweak the server to send the correct real HTTP headers.

    This caching tutorial is a very good primer on how caching works (and why you shouldn't try to disable it unless you know what you're doing).
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    no-cache gets ignored by FF so when you have for instance a form and you need the browser to NOT cache it you'll have no-cache no-store which FF will follow. IE obeys no-cache pretty well-- it'll break the Back button on POST forms if you're not careful.

    Using the tag I'm pretty sure is for forms with POST methods only. Everything else preferably via the server headers as Tommy said.

    As a user I never have the problem of cached pages as I always type in the URL or choose via a Bookmark. I don't use Opera's weirdo page (speed dial? I have little blank squares I ignore), I don't let Firefox save its tabs when open, and I never click on Chrome's "most visited pages" thingie. Users who leave their tabs and stuff open should not complain about not seeing new content. Don't they know it's not the real page they're seeing but what the browser remembers?
    Reminds me of my mom who would drive around and not know what the "little flag in the water light" meant. Maybe some user education is necessary? It would at least help them with other sites they're not seeing fresh.

  5. #5
    SitePoint Addict trinity0159's Avatar
    Join Date
    Jul 2002
    Location
    California
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Schulz View Post
    If you use the tag the search engines will honor it, meaning that your pages will not be cached in their indexes.
    I read somewhere that it does lower your rank in search engines, is this true?

  6. #6
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,589
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trinity0159 View Post
    I read somewhere that it does lower your rank in search engines, is this true?
    It shouldn't. The point of the caching system that google uses is not to provide indexing services.
    Always looking for web design/development work. Willing to do it cheap to build portfolio!

  7. #7
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I read somewhere that it does lower your rank in search engines, is this true?
    Trinity, think of all those authorised banking pages where you log in to view your account. Because they're secure, they are never cached, by anyone. Does that hurt banking sites? Nope. Their cacheble pages show up just fine. So, you're cool.

    That link from Tommy was pretty cool. I bookmarked it. Unless I'm confusing it with a mirror, I've never heard of a proxy cache before. I wonder if there's any way to know that when I'm accessing a site whether I'm actually sending a GET request to that server or to some proxy somewhere in teh Tubes...?

  8. #8
    SitePoint Addict trinity0159's Avatar
    Join Date
    Jul 2002
    Location
    California
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the advice. I think I will go ahead and use it. My primary daily users will be using IE6 (ick) so I'm not too worried about the occassional FF users that might have to hit refresh if needed.

    Should I use the format below with the additional head tags at the bottom for IE issues or is it not needed.

    Code:
    <meta http-equiv=“Expires” content=“0”>
    <meta http-equiv=“Pragma” content=“no-cache”>
    <meta http-equiv=“Cache-Control” content=“no-cache”>
    To get it to delete at a special time, such as midnight, use
    <META HTTP-EQUIV=“Expires” CONTENT=“Fri, 19 Oct 200400:00:00 GMT”> 
    To affect Internet Explorer 4, you have to add a second <head></head> block at the end of your html code, after the </body> tag but before the </html> tag and insert a duplicate of the Pragma=no-cache tag:
    <HTML>
    <HEAD>
    <META HTTP-EQUIV=REFRESH CONTENT=5>
    <TITLE> Pragma No-cache </TITLE>
    </HEAD>
    <BODY>
    ??
    </BODY>
    <HEAD>
    <META HTTP-EQUIV=PRAGMA CONTENT=NO-CACHE>
    </HEAD>
    </HTML>
    Thanks again!

  9. #9
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,276
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    I didn't check it to see if it was 100% true, but as far as I know you get one <head> per document. The second one should be illegal.

    Second, Tommy's link will tell you that while you can stick all those meta tags on your page, the HTTP headers on the server (if you have any) will override them, and frankly, you can't count on all user agents (browsers) obeying the meta tags but they WILL obey most if not all of the HTTP headers (assuming you're using HTTP1.1 cause it seems everyone does nowadays).

    Third, your quotes shure look fuhnny. "" are the correct quotes, not the funny strange angled ones (each different type of quote really is a completely different character as far as computers are concerned). So assuming you have zero control over your server or you just want to keep the meta tags in your page anyway, change the funny quotes to regular straight ones.

  10. #10
    SitePoint Addict trinity0159's Avatar
    Join Date
    Jul 2002
    Location
    California
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the advice. I took the HTML above from the microsoft site on their fix for IE so yes, I will definitely be fixing the funny quotes. I read the advice about adding the double head tags from the site below. http://www.htmlgoodies.com/beyond/re...le.php/3472881

    One more questions, please...

    Does editing the http headers on the server also fix the problem of pdfs that get updated but sometimes users having to hit refresh to see the updated pdf?

  11. #11
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trinity0159 View Post
    Does editing the http headers on the server also fix the problem of pdfs that get updated but sometimes users having to hit refresh to see the updated pdf?
    It should, if you set a reasonable expiry date for them. The trick is to find the right balance: if they expire too soon you waste bandwidth and your users experience poor site performance; if they expire too late users may miss updates.

    Normally, setting Cache-Control: must-revalidate should solve the latter problem. It means user agents should always check for freshness before using a cached version (using an If-Modified-Since header). If the server responds with a 304 the user agent will know its cached copy is still fresh.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •