Results 1 to 7 of 7

Thread: updating temp files

  1. #1
    Join Date
    Dec 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question updating temp files

    Is there a tag that can be inserted into the <head> so at anytime a user visits a page, it automatically checks for a recent version and updated the temp files. that way the user isnt browsing the site with old files, or has to refresh a few times to make sure he has updated files. thanks in advance

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    I think what you want is to stop the browser from caching you page. This can be done with a meta tag in the head section:
    HTML Code:
    <meta http-equiv="PRAGMA" content="NO-CACHE">
    Unfortunately this is not enough for IE since it caches in a different way. The solution (from Microsoft Support) is to add extra head tags between the </body> tag and the </html> tag where you insert the same code. The entire page should then look something like this:
    HTML Code:
    <html>
    <head>
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    <title>Untitled Document</title>
    </head>
    <body>Body content of the page
    </body>
    <head>
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    </head>
    </html>
    Of course, this will not validate because of the extra head tags. There might be other ways to do this, but I think this is the simplest one.

    Edit: I forgot that IE5 doesn't accept PRAGMA so you need to use this to prevent IE5 users from caching your page:
    HTML Code:
    <meta http-equiv="Expires" content="-1" />
    That makes the page expire the moment it's created. The final code would then be:
    HTML Code:
    <html>
    <head>
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    <meta http-equiv="Expires" content="-1" />
    <title>Untitled Document</title>
    </head>
    <body>Body content of the page
    </body>
    <head>
    <meta http-equiv="PRAGMA" content="NO-CACHE" />
    <meta http-equiv="Expires" content="-1" />
    </head>
    </html>
    I'm not sure if you need this IE5 meta tag in the first head section but it's better to be safe.
    Last edited by Snookerman; 12-11-2008 at 11:10 PM.

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What on Earth is with the two <head>s? You don't need two <head> sections, and any browser that requires this mess is horribly broken.

    IE7 is out; IE5 isn't supported by Microsoft any more, and shouldn't be supported by developers either. It's a BRPOC, and mangling code to work around it is no longer worth the effort.

    Disabling caching entirely wasn't actually the request, and should almost never be done. Rather, an E-Tag header in the HTTP response can be used to indicate when a page has been modified and should be re-downloaded. If your page is dynamic then you may wish to generate this manually; otherwise, your webserver should be configurable to generate it from the file content or mtime, thereby keeping it automatically updated.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Yeah, I thought it was strange too, but that's what Microsoft and other articles on the net say:

    http://support.microsoft.com/kb/222064
    http://support.microsoft.com/kb/234067/EN-US/
    http://www.zann-marketing.com/developer/20051018/stop-browser-caching-using-meta-tags.html
    http://www.htmlgoodies.com/beyond/reference/article.php/3472881

    If the OP doesn't want to do this, they can do what they want, I'm just trying to help.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The second article mentions nothing about this. The first does, but it seems that the other two articles you have mentioned completely misunderstood it. The article notes only that the page will be saved to the cache, but it will not as such actually be cached.

    According to that article, it goes something like this:
    1. IE starts downloaded the page, sees the <meta> tag, and looks for the page in the cache. Since this is the first time the page has been downloaded, it does not exist, and nothing happens.
    2. When IE reaches the 32KB limit, it saves the page to the cache, ignoring the previously-encountered <meta> tag.
    3. When the page is downloaded for the second time, within the first 32KB the <meta> tag is once again encountered, but this time there is a page in the cache. Since the <meta> tag tells IE to ignore it, IE deletes the cached page and continues to download.
    4. When it hits the 32KB limit, the page is once again saved to the cache.
    As you can see, this means that despite the presence of the page in the cache, it is never used: the page is deleted and re-downloaded each time. There is no need for the extra <head>, and unless the page is larger than 32KB (which very few pages, being plain text, are — that's 32768 characters in most encodings!) the article seems to suggest that no caching will occur anyway.

    There appears to be no pressing reason to mangle one's page in this manner — even in the unlikely event that disabling caching is in fact necessary in this particular case.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Yeah, I agree that the whole thing seems a bit dodgy, I just assumed it was correct since Microsoft support seemed to agree. The second article was about pragma not working in IE5, in case there are still people out there using that.

    Like you said, maybe the OP doesn't even want this, maybe they could be more specific about what they want.

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If this were an issue, a better idea would be to insert 32KB of some sort of padding in front of the <meta> tag.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •