Results 1 to 6 of 6

Thread: If page content is New, Refresh Page

  1. #1
    Join Date
    Sep 2004
    Location
    Little Falls, Roodepoort, South Africa
    Posts
    421
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default If page content is New, Refresh Page

    Hi Guys

    I'm looking for a script that looks at the page(s) content and is not the same as in the cache etc, refreshes the page on load.

    Any suggestions...
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In javascript, not that I know of. Other than this battery of meta tags (may be others, these not 100% effective in all browsers, I am told):

    HTML Code:
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="Expires" content="Mon, 01 Jan 1990 12:00:00 GMT">
        <meta http-equiv="Cache-control" content="no-cache">
        <meta http-equiv="Cache-control" content="must-revalidate">
        <meta http-equiv="Cache-control" content="max-age=0">
    I'm not, as I say, aware of anything in javascript however, due to some experiences as webmaster on various servers over the years, it appears to me that there must be something server side that can affect this to a degree, with individual browsers having some say in the matter.

    Neither of these two avenues refreshes the page per se rather, they detect if there is new content and have the browser serve from the source instead of the cache or always serve from the source - if that is allowed by the browser's settings/default behavior.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2004
    Location
    Little Falls, Roodepoort, South Africa
    Posts
    421
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    Thanks John.. as always.....
    Very Best Rgds, Simonf :cool:
    __________________________________
    My Site | E-Mail Me

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    In javascript, not that I know of.
    There isn't any way.

    Other than this battery of meta tags (may be others, these not 100% effective in all browsers, I am told):
    User agents aren't required to respect meta elements at all, and intervening caches, which can be just as important as the browser (if not more), will never check them. HTTP headers should always be sent by the server.

    HTML Code:
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="Expires" content="Mon, 01 Jan 1990 12:00:00 GMT">
        <meta http-equiv="Cache-control" content="no-cache">
        <meta http-equiv="Cache-control" content="must-revalidate">
        <meta http-equiv="Cache-control" content="max-age=0">
    I have issue with the first and third elements (or their proper HTTP equivalents). Attempting to prevent any sort of caching is rarely productive, and only forces the client to make requests that it may not need to do. Trying to prevent caching is appropriate if the resource always changes, or in an effort to protect privacy, but should be avoided at other times. Caching is your friend.

    What is important in this situation is revalidation. This will automatically occur whenever the cache finds the resource to be stale. Properly chosen Expires header and max-age Cache-Control directive values will accomplish this just fine.

    [...] with individual browsers having some say in the matter.
    As always, the user has the final say. If they configure their browser to only revalidate periodically, rather than whenever indicated by the server, there's little that can be done.

    One approach is to make the URL unique, usually by adding a timestamp to the query string. As the majority of the URL (all of it except the fragment, if present) identifies a resource, even changing the query string will make the browser consider it to be different, forcing an end-to-end request.

    Mike

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Mike
    Originally Posted by jscheuer1
    In javascript, not that I know of.
    There isn't any way.
    Quote Originally Posted by Mike
    One approach is to make the URL unique, usually by adding a timestamp to the query string. As the majority of the URL (all of it except the fragment, if present) identifies a resource, even changing the query string will make the browser consider it to be different, forcing an end-to-end request.
    A circular post in that the query string could be appended via javascript. I know this would be a javascript enabled only solution but, perhaps that is all simonf requires.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    A circular post in that the query string could be appended via javascript.
    I never said that scripting couldn't be used as part of a solution to the general problem of retrieving fresh versions of a resource, just that it couldn't be used to do what Simon asked: to compare cached and origin content, and force an update if the former is out-of-date.

    I know this would be a javascript enabled only solution but, perhaps that is all simonf requires.
    Perhaps, but sending accurate HTTP headers is still a good idea.

    Mike

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
  •