question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browser caching does not work with range request set for Firefox

See original GitHub issue

Dear 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:

  1. clear the browser cache
  2. go to https://app.fays.io/fd7be64d-ec78-4731-9dff-7b9c8088acf9 and open the developper tool
  3. 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. Capture d’écran 2020-02-14 à 22 04 47 Capture d’écran 2020-02-14 à 22 26 15 A page refresh leads to: Capture d’écran 2020-02-14 à 23 49 30

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.

Capture d’écran 2020-02-14 à 22 02 34 Capture d’écran 2020-02-14 à 22 26 49

**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:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Snuffleupaguscommented, Feb 15, 2020

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.

1reaction
Snuffleupaguscommented, Feb 14, 2020

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):

If you are developing a custom solution, first check the examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare a short well-documented example that demonstrates the problem and make it accessible online on your website, JS Bin, GitHub, etc. before opening a new issue or contacting us on the IRC channel

Read more comments on GitHub >

github_iconTop Results From Across the Web

626027 - HTTP byte range requests are not cached
In these cases firefox requests byte ranges instead of the whole file. The server replies are not properly cached but are fetched again...
Read more >
HTTP range requests are not cached by Firefox nor Chrome
I'm dealing with the same issue. I've setup this demo, where the caching does work for range-header requests jsfiddle.net/3vjstogr , but ...
Read more >
How to Clear Your Browser Cache - Fort Valley State University
Firefox clear cache · Click the menu button. and select Options. · Select the Privacy & Security panel. · In the Cookies and...
Read more >
How to Clear Cache for All Major Browsers - Kinsta
It's a necessary diagnostic when having website issues (like a ... If the requested content is found within the browser cache, our Firefox...
Read more >
Caching Behavior of Web Browsers - F5 Networks
Hitting CTRL and refresh (in Internet Explorer only) or CTRL and F5 (Internet Explorer and Firefox) will insert a "Cache-Control=no-cache" header in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found