Topic: Disabling Cache (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=30697" title="Pages that link to Topic: Disabling Cache (Page 1 of 1)" rel="nofollow" >Topic: Disabling Cache <span class="small">(Page 1 of 1)</span>\

 
bjwaters
Nervous Wreck (II) Inmate

From:
Insane since: Apr 2008

posted posted 12-09-2008 17:50

Is it possible to disable the caching of a certain webpage. I have an image that is pulled from the server that displays a unique PIN that my customers are required to write down. The only problem I have is that this image is cached so when they purchase a second product after some time the same image is displayed and not a new one. Does anyone have any suggestions for this problem?

Thanks,

B.

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-10-2008 09:16

Yes. Send the appropriate headers. that basically 'don't cache, must refresh every time, expired three weeks ago'.

The php->header function documentation has some on this, and should get you started for further googling.

So long

->Tyberius Prime

bjwaters
Nervous Wreck (II) Inmate

From:
Insane since: Apr 2008

posted posted 12-10-2008 19:01

I used the following code, but in OSCommerce I receive the error:

quote:
Warning: Cannot modify header information - headers already sent by (output started at /home/getyourn/public_html/catalog/checkout_success5468.php:65) in /home/getyourn/public_html/catalog/checkout_success5468.php on line 76

Warning: Cannot modify header information - headers already sent by (output started at /home/getyourn/public_html/catalog/checkout_success5468.php:65) in /home/getyourn/public_html/catalog/checkout_success5468.php on line 77




Code:

quote:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>



It seems that i Oscommerce the headers are set by another file; a file that I do not know of.


I also thought if I used PHP to call the image (because I thought I rememberd that images called by PHP are not cached) that my problem would be solved.
I used the code:

code:
<?php 
print "<img src='yourfile.jpg?".time()."'>"; 
?>



To add some information to the URL, but once again my image was cached. Any ideas?

(Edited by bjwaters on 12-10-2008 19:45)

Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

posted posted 12-10-2008 20:41

The header() functions must be the absolute first thing in the file (before includes etc) or otherwise they may not work and this also means that they can't be in one of the included files at least this is the safest way to go about it.

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 12-11-2008 10:57
quote:

bjwaters said:
I also thought if I used PHP to call the image (because I thought I rememberd that images called by PHP are not cached) that my problem would be solved.


That notion is completly bonkers. The browser sees nothing different than would have been there without PHP.

php->Header() must be called before any output has been done. I.e. all include files before must have been complete blocks
of <?php ... ?> without newlines before or after (or any printing in between).

But I don't know if you're on the right track yet: You have to write a script that delivers the image file.
Sure, it needs to load the OsCommerce session data and database connection to retrieve the pin,
but afterwards it has to output the binary image data. Actually, I guess you already have such a script to generate the PINs,
then all you need to do is place the header() calls at its start.

But looking at it from another way: Why are your PINs in images anyhow? Wouldn't just printing them in the web page be enough
for the user to write them down?

So long,

->Tyberius Prime

bjwaters
Nervous Wreck (II) Inmate

From:
Insane since: Apr 2008

posted posted 12-11-2008 15:53
quote:
But looking at it from another way: Why are your PINs in images anyhow? Wouldn't just printing them in the web page be enough
for the user to write them down?



Yes, that would work. However, the software that I use to generate the PIN is a third party app and they use an image to display the PIN. After the PIN is used it is discarded and will not be displayed again.

bjwaters
Nervous Wreck (II) Inmate

From:
Insane since: Apr 2008

posted posted 02-07-2009 21:07

I know that it has been a while since I have visited this thread, but this problem still exists for me. I went about trying to set a no-cache just on the image, but this didn't work either:

code:
<img src="myimage.png?<?php echo filemtime('myimage.png') ?>">



Is the problem due to the fact that the image that is called does not have an extension, but rather:

<img alt="Unable to retrieve your PIN from the database. Please contact your e-book supplier for a valid PIN code." src="http://www.ebookgold.com/ModAuthor/DisplayPin/36928/" border="0">



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu