0

I know that headers can ensure a page that is fetched is always fresh: How to control web page caching, across all browsers?

But I just need to fetch a PDF in a new window. I'm using the following code to fetch the PDF, but how can I make sure the PDF itself a fresh (non-cached version)?

<a href='/somepath/doc.pdf' id='pdf' target='_blank'>View PDF</a>

Because my application dynamically creates PDF documents all the time, I want the most recent one. Is it not possible to do this simply? Or do I need to write a PHP page dedicated for this or something?

Community
  • 1
  • 1
user961627
  • 11,059
  • 35
  • 119
  • 202
  • What PDF-reader (browser-plugin?), OS and browser are you targeting? – berkes Feb 11 '13 at 09:34
  • Chrome, IE, Firefox. No PDF reader, just relying on the browser, regardless of OS. (PDF is platform-independent, and the browsers have their own way of handling PDFs, right?) – user961627 Feb 11 '13 at 09:43
  • 1
    this might sound like a stupid solution, but could you not just a querystring to the URL, and each time use something random... like "/somepath/doc.pdf?blah=12345" – SQLGuru Feb 11 '13 at 09:46
  • @SQLGuru: Your train of thought is the proper one. However, parameters are a bad idea [fingerprinting](http://guides.rubyonrails.org/asset_pipeline.html#what-is-fingerprinting-and-why-should-i-care) is a better way. – berkes Feb 11 '13 at 12:14

0 Answers0