Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: How to force perl script to be refreshed

by Prior Nacre V (Hermit)
on Oct 11, 2004 at 10:04 UTC ( #398125=note: print w/replies, xml ) Need Help??


in reply to How to force perl script to be refreshed

You can stop the browser reading a cached page by making all URIs unique.

You can do a quick-and-dirty by adding a random number to the URI's query string (as shown in test output below).

[ ~/tmp ] $ perl -wle 'use strict; print join("", "fred.pl", "?dummy=" +, rand)' fred.pl?dummy=0.67350901065311 [ ~/tmp ] $ perl -wle 'use strict; print join("", "fred.pl", "?dummy=" +, rand)' fred.pl?dummy=0.079789433236332 [ ~/tmp ] $ perl -wle 'use strict; print join("", "fred.pl", "?dummy=" +, rand)' fred.pl?dummy=0.844672383115725 [ ~/tmp ] $ perl -wle 'use strict; print join("", "fred.pl", "?dummy=" +, rand)' fred.pl?dummy=0.288386549874307 [ ~/tmp ] $

To guarantee uniqueness, you'll need to replace rand with a call to something that will return a unique value - possibly a custom-built application which returns a unique value, reading the nextval from an Oracle sequence or something along those lines.

Regards,

PN5

Replies are listed 'Best First'.
Re^2: How to force perl script to be refreshed
by stevecomrie (Beadle) on Oct 12, 2004 at 12:01 UTC
    using the epoch works just as well as random numbers.
    Perl: my $time = time; JavaScript: var now = new Date(); var epoch = now.getTime();
    Attach either of those to the end of a link and the browser will no cache the output.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2022-05-28 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (98 votes). Check out past polls.

    Notices?