Jump to content
xisto Community
kvarnerexpress

Forcing A Page To Not Load From Cache

Recommended Posts

I've developed a page that is composed of HTML and PHP and it pulls info from a DB to create a dynamic page. The one issue I'm seeing is that I'm having to hit refresh to get the page to pull information newly added to the DB. The browser seems to be pulling from cache. Is there a tag or script I can use to tell the browser to never pull this page from cache? Thanks.kvarnerexpress

Share this post


Link to post
Share on other sites

Using PHP:

if( !headers_sent() ){   header('Expires: ' . gmdate('D, d M Y H:i:s') . 'GMT');     header('Cache-control: no-cache');}

Or using plain HTML:
<META HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">

Of course, you may put any expiration date, the ones above are merely examples, though they would expire the content immediatley!

I hope that helps!

Share this post


Link to post
Share on other sites

The one issue I'm seeing is that I'm having to hit refresh to get the page to pull information newly added to the DB.

So you're looking at a page, then you update the database and then you have to refresh your page to see the changes? Well I'm afraid that's the only way it's gonna work. How else is the page gonna update unless you refresh the browser?
Unless you're talking about having to refresh more than once to see the changes. If you're talking about just one single refresh, then that's completely normal.

Share this post


Link to post
Share on other sites

Can this be done without PHP... maybe just Javascript ?

It can be useful for me if it's done on Javascript...

149905[/snapback]


Or using plain HTML:

<META HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">

Of course, you may put any expiration date, the ones above are merely examples, though they would expire the content immediatley!

 


Yes, it can be done without PHP, just look at the example I posted using HTML.. :D

Share this post


Link to post
Share on other sites

The thing about doing it in Javascript is that not everyone has Javascript enabled. If it's really important to make your pages dynamic, you should do it with something that people can't turn off.That, and it may not even be possible to do it with Javascript.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.