Browser caching does not work with range request set for Firefox
See original GitHub issueDear PDF.JS contributors,
When range requests are set and http server configured to cache contents with public, max-age=31536000, immutable,
browser caching does not work on Firefox but strangely it works on Chrome or Safari.
Attach (recommended) or Link to PDF file here: not file specific, but one can use https://public.fays.io/public/c80f5905-e4aa-4df3-8fa8-ab2dd3d04320.pdf
The server configuration is:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, HEAD, PUT, POST
Access-Control-Expose-Headers: Accept-Ranges, Content-Range, Content-Length, x-amz-request-id, x-amz-id-2, ETag
Access-Control-Max-Age: 31536000
Vary: Origin, Access-Control-Request-Headers, Access-Control-Request-Method
Cache-Control: public, max-age=31536000, immutable
Configuration:
Web browser and its version: Firefox 73.0
Operating system and its version: mac os x 10.15.3
PDF.js version: 2.2.228
Is a browser extension: no
Steps to reproduce the problem:
- clear the browser cache
- go to https://app.fays.io/fd7be64d-ec78-4731-9dff-7b9c8088acf9 and open the developper tool
- refresh the page, the range request works fine but they are not cached by Firefox (private browser cache: https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching)
What is the expected behavior?
On Chrome, when one refreshes the page, the range requests have been cached. A page refresh leads to:
What went wrong?
On Firefox, the range requests are not cached by the private browser cache.
Also, Firefox performs in this example a 1.2MB download because the first range request has Range: bytes=1577535-
and the response header has a code 206.
On the other hand, PDF.JS on Chrome requests bytes=0-262143
and the response header has a code 200.
I don’t know why it behaves differently.
**Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension): ** https://app.fays.io/fd7be64d-ec78-4731-9dff-7b9c8088acf9
Best, A.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
Given that caching is controlled by the browser itself, I’m not really sure that this is actually an actionable bug for the PDF.js library. If anything, it sounds more like a (possibly general) bug in Firefox and I’d thus suggest reporting it in Bugzilla instead.
When opening an issue, please provide all of the information requested in https://github.com/mozilla/pdf.js/blob/master/.github/ISSUE_TEMPLATE.md
Furthermore, the likelihood that someone will assist you is a lot greater with a small and self-contained example (rather than a larger viewer); please see https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md (emphasis mine):