Browser Won't Request Latest PDF from Server
Asked Answered
R

2

7

I have a PDF on Windows Server IIS web server, where users request it with IE8/9/10 using HTTP call like this...

http: // mydomain.com / somefolder / myFile.pdf

First hit will download the file no problem. Problem: if admin updates the PDF, and user goes back to reload it, IE only shows local cached version and will NOT request a new version from the server.

I have confirmed that on 2nd request, IE8, IE9, and IE10 do not call the server at all for the PDF file. Not even a conditional request (e.g., if-updated-since). Confirmed this using Fiddler and WireShark. But I never explicitly set the caching with Max-Age or anything. I have no caching set for that folder. I would prefer not to set cache to "expire immediately". It does this for Word DOC's also.

Is there a bug in Internet Explorer that makes it ALWAYS use local copies of static docs (e.g., PDFs, DOCs) no matter what?

These ideas do NOT work:

  1. F5, CTRL+F5, SHIFT+F5

  2. Clear the browser history and cache using the DELETE HISTORY button. Why this actually doesn't clear ALL the cache is beyond me. I have everything selected for deletion except passwords.

The only ways I know around this are:

  1. Manually delete the PDF locally because the "DELETE HISTORY" button does not delete the local version. But most users are not that savvy.

  2. Use Firefox but that's not a company-approved browser. Don't get me started.

  3. Set server caching to Expire Immediately, but pdfs are mixed in folders with web pages and I prefer not to do this. I want to use caching max age for other things like CSS, scripts, images, etc..

  4. Add a fake query string to the end like ?id=1, and that works, but the business line has 100's of docs each with links inside the docs that would have to be updated.

  5. Use FIDDLER "clear cache" button or CCleaner, but most users in my company (70k employees) are not developers and can't have that software.

Is there a real solution for this, to make IE behave like I thought it would?

Rateable answered 5/8, 2014 at 18:21 Comment(1)
I've had the same issue and chose to resolve it by setting client side cache to "expire immediately" on the IIS site through the Response Headers setting, using the simple approach described in iis.net/configreference/system.webserver/staticcontent/…. It surprised me having to use this setting, because I had previously done no caching settings at all - but apparently IE uses some a different default caching strategy if none is specified in the response header (which is IIS default), compared to e.g. Chrome.Vickievicksburg
T
4

I was able to change the htaccess file to add an age to the cache of pdf files. This worked perfectly for fixing this issue on IE and other browsers where a refresh or reopen of the browser fixed the problem.

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

<FilesMatch ".(pdf)$">
  Header set Cache-Control "max-age=0"
</FilesMatch>

</IfModule>
Thespian answered 15/5, 2015 at 23:39 Comment(0)
V
1

Similar to the answer by GNakano on using cache expiration per file type using .htaccess (on Apache), the following post describes how to set cache expiration per directory using web.config on IIS: How to configure static content cache per folder and extension in IIS7?

With this approach, you just need to place all .pdf and .docx in a separate folder (with no caching) and can then still have caching for your other stuff.

Vickievicksburg answered 5/7, 2016 at 9:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.