Chrome default PDF viewer re-downloads file on 'Download'

时间:2018-10-24 11:23:22

标签: javascript google-chrome http pdf

I have a webservice which generates PDF files on the fly and returns them to the user. On the client side the returned PDF file is opened in Chrome default PDF viewer.

The returned file has HTTP headers set so that it would be cached. I know it works because after generating and opening the file for the first time, after hitting refresh or even Ctrl-F5 (Windows), I see that the cached file is presented to the user.

However when I press 'Download' in the PDF viewer toolbar, the downloaded file is not offered for save - instead a new HTTP call is triggered with no "Cache-Control" header. Since the server does not keep a copy of the generated file, this request fails and the user gets a file download with an error message "Failed - No File".

Is there any way of allowing the user to save the file after opening it in the Chrome PDF viewer without storing the file server-side for repeated queries or relying on cache servers between the client and the server?

0 个答案:

没有答案