meltingpoint Posted August 1, 2013 Share Posted August 1, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/280736-pdf-cache-problem-old-pdf-served-not-new-one/ Share on other sites More sharing options...
kicken Posted August 2, 2013 Share Posted August 2, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/280736-pdf-cache-problem-old-pdf-served-not-new-one/#findComment-1443066 Share on other sites More sharing options...
meltingpoint Posted August 2, 2013 Author Share Posted August 2, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/280736-pdf-cache-problem-old-pdf-served-not-new-one/#findComment-1443068 Share on other sites More sharing options...
Solution meltingpoint Posted August 4, 2013 Author Solution Share Posted August 4, 2013 (edited) Placed the below in the .htaccess file and it works perfectly! <FilesMatch ".(pdf)$">FileETag None<ifModule mod_headers.c>Header unset ETagHeader 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 August 4, 2013 by meltingpoint Quote Link to comment https://forums.phpfreaks.com/topic/280736-pdf-cache-problem-old-pdf-served-not-new-one/#findComment-1443406 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.