Jump to content

Recommended Posts

Posted

I read dallara's question in the forum, and I have a similar ??.

 

I acccess a radar image on my site, what I would like to do is:

 

1. user clicks on "view radar"

 

2. radar page & image loads

 

3. page immediately reloads

 

4. page displays & just sits there.

 

5. There is a <meta http-equiv="refresh" content="420"> in the radar page code

to refresh the image after 7 minutes when the radar updates.

 

The problem is, currently, a visitor gets an old image and then has to wait 7 minutes for current.

 

I really don't want to deal with a whole lot of caching/non-caching if I can avoid it. Just a "simple" reload??

 

Your thoughts & suggestions are appreciated.

Posted (edited)

I would say either the meta refresh and PHP or Javascript.

 

At the VERY start of the page you'd put

 

><?php
$metaTag = '';
if (empty($_COOKIE['refreshed']))
{
  $metaTag = '<meta http-equiv="refresh" content="0">';
  setcookie('refreshed', 1);
}
?>

 

Then where the meta refresh tag goes put

 

><?php
echo $metaTag;
?>

 

This way the meta refresh tag should only appear the first time the page is loaded. I'd recommend this method over the javascript as a few may have javascript turned off.

Edited by carbonize
Posted (edited)

Hmm, I must be doing this wrong, it is displaying :

 

'setcookie('refreshed', 1);

 

at the top of the page ......

Edited by opus74
Posted
Did you copy my code exactly ?

 

Yes, just after <head>.

 

Here's a shot....GIF killed the graphics ......

 

sorry, I don't have upload permission here ... but it puts the 'setcookie('refreshed', 1); at the top of the page.

Posted

No

 

><?php
$metaTag = '';
if (empty($_COOKIE['refreshed']))
{
  $metaTag = '<meta http-equiv="refresh" content="0">';
  setcookie('refreshed', 1);
}
?>

 

That needs to be the very first thing on the page. Nothing before it. No white space, no HTML, nothing.

Posted

Opus -- I think that the problem might be that you put php code in a page that has an .html or .htm extension. If you rename the page to a .php extension then the code that Carbonize gave you will work fine.

 

Please note: If the page has been indexed by the search engines, or saved by users, then you will also want to put in a redirect for the "whatever_the_name_is.html" to "whatever_the_name_is.php".

Posted
Opus -- I think that the problem might be that you put php code in a page that has an .html or .htm extension. If you rename the page to a .php extension then the code that Carbonize gave you will work fine.

 

Please note: If the page has been indexed by the search engines, or saved by users, then you will also want to put in a redirect for the "whatever_the_name_is.html" to "whatever_the_name_is.php".

If the page does have an .html extension

put this in your .htaccess flie to make it work without changing the extension.

>AddHandler application/x-httpd-php .htm .html

 

And search engines indexing won't matter.

Posted
If the page does have an .html extension

put this in your .htaccess flie to make it work without changing the extension.

>AddHandler application/x-httpd-php .htm .html

 

And search engines indexing won't matter.

 

 

Don, I learn something new every time I read this forum. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...