stop the caching

Reply

Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

stop the caching

 
0
  #1
May 7th, 2008
i have created a website where the user is able to upload images and then they are displayed on and email which is then sent out to the people of there choice.

the problem i am getting is that the images are being cached and then the new images are not displaying.

i have used if file exist to display the images on the email and also used it to unlink the files once they have been used. When the user comes to use the system next time if they upload an image of the same file type then it is displaying the cached version and not the new image. if a image with a different file type is uploaded then it works, but this will only show different images as long as the file type has not been used.

i have tried using this

  1. <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
  2. <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">

which has had no effect on the situation. i put the above code inside the head tag is this the correct place to put it. the reason i put it there is because this is usually were the meta tags are placed.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,746
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: stop the caching

 
0
  #2
May 7th, 2008
Yep ! <head> tag is the right place to put meta tags. I haven't come across caching problem, but maybe you can use this.
  1. <?php
  2. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  3. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  4. ?>
Source: http://nl2.php.net/header Ex. 2
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: stop the caching

 
0
  #3
May 7th, 2008
i have tried that and had no joy. i checked on the server to see if it was a problem with the unlink code i have but it is defiantly uploading the images and removing the old files on the server. I know this as the time stamps for when the file was uploaded are changing.

i will have a good search around the web and see what i can find i will post it here if i find anything that works.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,746
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: stop the caching

 
0
  #4
May 7th, 2008
Hey, If you don't have any "processing" in your script, why not redirect the script to the same page ? Will it still have the images in the cache ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: stop the caching

 
0
  #5
May 8th, 2008
the images are being cached on the server i think and this why the same images show up on the emails i think. i am working on adding a random number to the image when it is uploaded and then using the post/get method to retrieve the value of the random number to use to display the image.

if a random number is added to the image then the image that is shown on the email page will always have a different value added to it so it should always show the new images that are uploaded.

well that is the theory behind it anyway weather it works or not is another thing.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: stop the caching

 
0
  #6
May 8th, 2008
is it possible to a random number to a image file without it becoming a part of that file name. what i want to do is where i am displaying the image add a random number so that the image when cached has this number attached to it but it is not part of the path to the file.

so i want it to be displayed by getting the file name then adding the number so that the number changes every time the page is viewed and the image cannot be displayed from the cach
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,746
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: stop the caching

 
0
  #7
May 8th, 2008
is it possible to a random number to a image file without it becoming a part of that file name.
No.. You can rename a file by concating a random number. You cant add random number to an image without changing its name..
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: stop the caching

 
0
  #8
May 8th, 2008
so would it be possible use the if file exists to retrieve the file and then on each individual page add a unique random number to each image so that they all have there own number attached to them.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,746
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: stop the caching

 
0
  #9
May 8th, 2008
I don't know what you mean by that.. But, if you use "if file exists" and add a random number to the image, What is the point in storing the filename in the table ?
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 347
Reputation: kevin wood is an unknown quantity at this point 
Solved Threads: 1
kevin wood's Avatar
kevin wood kevin wood is offline Offline
Posting Whiz

Re: stop the caching

 
0
  #10
May 8th, 2008
i am storing the files on the server so that they can be recalled when the email is sent out with the images held within it. the reason i want to add the random number after they have been stored is because the images are being cached.

the problem with the images getting cached is if the user comes and uploads a new image with the same file extension it will only show the cached version of the image. i have tried to stop the images getting cached with various different methods which in clude php headers and html meta tags, both methods failed.

so my next attempt at trying to get it show the new images is by adding a random number. if i store the number with the file i have no way of knowing the full path to the file once a random number has been added to it.

i tried a method were the random number that was generated was sent to the other pages with the session_start() function but that through up a load of errors with my code that is working fine without that in.

if i can get it to find the image without the random number attached to it then add this i am hoping this will stop the old images from being displayed on the pages. I know it is a problem with the images being cached because each time the upload page is entered it unlinks the last file that was uploaded.

hope that makes it a bit more clear.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC