Jump to content

pdf cache problem- old pdf served not new one


meltingpoint
Go to solution Solved by meltingpoint,

Recommended Posts

I have a website where I allow people to submit a .pdf file and it is then displayed in an iframe or in a pdf object in a div.  The names of the files always stay the same, and are uploaded to a specific folder.

 

Problem is- when they upload a new .pdf file....the browser always displays the old .pdf file. 

 

Deleting temp files- doesn't change.

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">  does not work

 

Is there a way to make sure that the current and updated pdf file gets served to the browser and it displays it?

 

Any suggestions would help.

 

Andy

Link to comment
Share on other sites

You need to make sure the PDF file itself is served with the proper no cache headers, which means either modifying the server config or serving the file via PHP.

 

Another option is the append a query string to the pdf url that changes each time (or at minimum when the pdf is changed). A random number, or the pdf file's last modified date would work for this.

Link to comment
Share on other sites

I would like to say away form appending the url if possible.

 

Is there a way to serve it up with php so as to pull the newest updated file?  If yes, can you point me in the direction as to how that is done.  I have a support ticket with my host to see if it is something they can change on their end for me.

 

Thanks- Keith

Link to comment
Share on other sites

  • Solution

Placed the below in the .htaccess file and it works perfectly!

 

<FilesMatch ".(pdf)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</FilesMatch>

 

Excellent!

Keith

Edited by meltingpoint
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.