Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: how to refresh a page immediately

by little (Curate)
on May 04, 2003 at 11:50 UTC ( #255464=note: print w/ replies, xml ) Need Help??


in reply to how to refresh a page immediately

YOU CAN NOT FORCE THE BROWSER TO MAKE A REFRESH utilizing HTML. (Only the user can "reload" or "refresh" the page wich means to repeat the request for the document(s) from the server) with all parameteres unchanged utilizing his / her browser. It's a client side action)

You can REDIRECT THE BROWSER to a URL utilzing HTML even if this is the same as the former one.

Why I prenounce that is simply the way the browser requests a page. When a browser requests a document from a webserver that browser will also remit ALL cookies originating from that webservers qualified domain and all those cookies which the browser is additionally allowed to submit to that specific web server. In repsonse the webser will return the requested document AND the new cookies. If a new cookie has the same identifier as one previously written by the same server the old cookie will be overwritten or actualized so to speak.) So when your script is being executed due to a call for your scripts URI the webserver will hand all received data to your script. When using CGI.pm you have an easy task. Simply write the new cookies before you start delivering content as the cookies are being sent in the document header.

A small example:

#!/usr/bin/perl -wT use strict; $|++; use CGI qw/:standard /; use CGI::Cookie; # dont allow that tiny script to crack this server $CGI::DISABLE_UPLOADS = 1; # set this to a reasonable high amount preventing server attacks with +posting hughe files $CGI::POST_MAX = 15000; # please identify, somehow my $usrPc = remote_host(); # if you've been here before, tell me, as whom you identified my $usrWasLast = (cookie('ID'))? cookie('ID'):'none'; # what kinda browser ? my $usrAgent = user_agent(); # well, get a cookie, please accept it, and if not, I don't need that +info from you anyway :-) my $hiddenInfo = new CGI::Cookie( -name=>'ID', -value=>$usrPc, -expires=>'+3M', -domain=>'little.perlmonk.org' ); my $referrer = param('ref') if (param('ref')); # now give the browser what it requested print header( -charset=>'iso-8859-1', -cookie=>[$hiddenInfo] ); print start_html( -dtd=>'-//W3C//DTD HTML 4.01 Transitional//EN', -lang=> 'en', -title=> 'yourPageTITLE' ); print p(($usrWasLast)? "You've been here before using IP: " . $usrWasL +ast : "I don't know you."); print p('You have followed a link to this site from' . $referrer) if d +efined $referrer; print end_html(); # 1;

Have a nice day
All decision is left to your taste


Comment on Re: how to refresh a page immediately
Download Code
Re^2: how to refresh a page immediately (forced refresh)
by Aristotle (Chancellor) on May 04, 2003 at 13:58 UTC

      nice snippet but that does not force a reload or refresh (just a repetetion of the first request) instead it just forces the browser to NOT to CACHE the document content you delivered, so he will noct used previously cahced version to be displayed.

      You could instead use HTTP (via CGI.pm), send from your script a "document created - see here"-Header follwed by your own scripts URL but that prohibits sending any content after such redirection header.

      Have a nice day
      All decision is left to your taste

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://255464]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (15)
As of 2014-08-29 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (281 votes), past polls