Jump to content

PHP, MySQL, page refresh


Payload9

Recommended Posts

Hi Everyone,

 

I am a new member here, as well as new to the world of PHP.  I have an O'Riley book on "learning PHP" and it has been good so far.

 

What I have done so far is create a page that will parse out a unique URI and return it's contents to a MySQL database.  I have set up three statements to run.

 

The first statement says, if there's nothing in the MySQL database, then display "we didn't find anything so we populated the MySQL database".  The MySQL database is then populated with the unique URI information.

 

The second statement says, if this unique URI is present in the MySQL database, but the field "tcode" is NULL then display "we found this in the database already, but tcode is not populated".

 

The third statment says, if this unique URI is present in the MySQL database, and the field "tcode" is not NULL then display "we found this in the database already, and tcode IS populated".

 

All of those statements work, the problem is when I go to a different page, any page (like yahoo) then select the php URI from the browsers address bar that I have just used, the page does not reload.  It simply uses the cached information from the browser, and I do not want this to happen.  Keep in mind, if I press F5 or the "refresh" button, then the PHP code is re-processed.  Or if I open up a new browser session and use the URI then the page is again, re-processed.  It only does not re-process when the URI is used in the same browser session.

 

Is there a way to make PHP re process the page every time a user hits the page?

 

Thanks in advance.  :)

Link to comment
Share on other sites

Thanks for the reply.  I thought this was probably a client side issue, but I wanted to try and make sure I wasn't assuming something that wasn't true.

 

I found a couple of commands that seemed interesting like "ob_flush" and "flush".  But I can't quite tell if these functions will do anything client side.  Or force a browser to re-process the PHP code.  Any thoughts?

Link to comment
Share on other sites

you can use headers to try and prevent browsers from caching the page.

 

 

this should work:

 

<?php 

// Date in the past 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 

// always modified 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 

// HTTP/1.1 
header("cache-Control: no-store, no-cache, must-revalidate"); 
header("cache-Control: post-check=0, pre-check=0", false); 

// HTTP/1.0 
header("Pragma: no-cache"); 
?> 

 

You can also stop search bots like google from caching your pages by adding this meta tag:

<meta name="robots" content="noarchive">

-----

 

for more information see http://www.searchengineworld.com/r/redirect.cgi?f=21&d=10628&url=http://www.mnot.net/cache_docs/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

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.