Hello,

I've got a a special page with a webcam picture on it and this picture gets actualised every 5 minutes via FTP directly on the server. Now I would like disable browser caching for this single page. I know that for this I need to use the following HTML META tags:


but now my question is how do I get these into my specific webcam node page ?

Regards

Comments

sgriffin’s picture

put into your page tpl a loop.

http://drupal.org/node/115419

based on whatever matched your node
I use headers and not meta tags for non-cacheing
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}

mlnospam’s picture

Great, thanks for your help, it works really fine. So maybe for the others (who like to copy/paste code) :) here is what I added to my page.tpl.php (at the very top of this file):

if (arg(0) == 'node' && is_numeric(arg(1))) {
        $nid = arg(1);
        if ($nid == 17) {
                header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                header("Cache-Control: no-store, no-cache, must-revalidate");
                header("Cache-Control: post-check=0, pre-check=0", false);
                header("Pragma: no-cache");
        }
}

This code says that my node with ID 17 will get the special headers set to disable caching of this page...

kriskd’s picture

I was also looking for something like this for my webcam page.

For simplicity, I just put

<?php
                header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                header("Cache-Control: no-store, no-cache, must-revalidate");
                header("Cache-Control: post-check=0, pre-check=0", false);
                header("Pragma: no-cache");
?>

at the top of my page.tpl.php page so (hopefully) nothing would be cached by the browser. Then, I cleared my cache, visited my site and then reviewed what was in Firefox's cache (via about:cache in the address bar) and there are all my webcam image there cached.

Did I do something wrong, or are these the intended results?

schildi’s picture

First I tried to put the code mentioned above at the very top of page.tpl.php with no avail.
In a second try the code was placed just after the "print $head" line. No avail either:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language ?>" lang="<?php print $language ?>">
  <head>
    <?php print $head ?>
    <?php
        if (arg(0) == 'node' && is_numeric(arg(1))) {
                $nid = arg(1);
                if ($nid == 15639) {
                        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                        header("Cache-Control: no-store, no-cache, must-revalidate");
                        header("Cache-Control: post-check=0, pre-check=0", false);
                        header("Pragma: no-cache");
                }
        }
    ?>
    <title><?php print $head_title ?></title>

when checking the code of the generated page I see that there is no line containing the text "cache-control".

I an other try the lines

    print '<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE" />';
    print '<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE" />';

were placed in the block (s. above). In that case these two line appear. Bit it looks that the page is NOT generated for each browser call (anonymous user).