/    Sign up×
Community /Pin to ProfileBookmark

Script to update html files?

Hi
I was wondering if there is a php script that will load the latest version of a html file, as normally with html files it loads the old one in the user’s cache untill they clean their cache out.
So for example:
[url]www.something.com/about.php[/url]
would load the latest server version of:
[url]www.something.com/about.html[/url]

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@shimonSep 14.2004 — Not really a PHP script, but you could try adding some meta tags to your page to tell the browser not to cache the page, like so:
[code=php]
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="cache-Control" content="no-cache" />
[/code]

That seems to work for me ?
Copy linkTweet thisAlerts:
@NogDogSep 14.2004 — www.something.com/about.php:
[code=php]<?php
header("Location: http://www.something.com/about.html");
?>[/code]

This would load the desired html file, but I'm not sure whether the browser would still use the cached version or not if available. Or maybe this would work:
[code=php]<?php
$lines = file('about.html');
foreach($lines as $line)
{
echo $line;
}
?>[/code]
Copy linkTweet thisAlerts:
@try2dreamauthorSep 16.2004 — Thanks for the code NogDog, but both didnt work.
Copy linkTweet thisAlerts:
@JonaSep 16.2004 — [font=trebuchet ms]The forum messed up NogDog's post.[/font]

[code=php]
<?php
header("Location: http://www.something.com/about.html");
?>
[/code]
Copy linkTweet thisAlerts:
@try2dreamauthorSep 16.2004 — Thanks Jona, but that redirects to the html and doesnt refresh the cache version.
Copy linkTweet thisAlerts:
@solavarSep 16.2004 — One method I've found to be effective, where others fail, is to append a question mark at the end...

<i>
</i>&lt;?php
header("Location: <a href="http://www.something.com/about.html?">http://www.something.com/about.html?</a>");
?&gt;


The question mark tricks the browser into thinking this is a querystring which must be handled by the webserver rather than simply grabbing a cached copy.
Copy linkTweet thisAlerts:
@try2dreamauthorSep 16.2004 — nice one solavar
Copy linkTweet thisAlerts:
@solavarSep 16.2004 — ...happy to help


?
×

Success!

Help @try2dream spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...