FEATURE: Use range requests for PDF previews whenever possible, do not download entire file #3856
Labels
backend
Issues related to Aleph’s backend, API, CLI etc.
feature-request
Requests for new features or enhancements of existing features
ui
Issues related to Aleph’s frontend
Is your feature request related to a problem? Please describe.
PDF files can be optimized to be served by web servers that support range requests. A range request only downloads a parts of a file, e.g. only the byte range required to render a specific page. PDF files that are optimized for this are often also referred to as "linearized" or "web optimized" PDF files.
Describe the solution you'd like
We could make better use of range requests:
Disable auto-fetching
We use pdf.js (via react-pdf) which supports range requests. In fact, PDF.js by default will try to use range requests if supported. This speeds up rendering of the first page. However, after downloading the part of the file required to render the first page, PDF.js will still try to preload the rest of the file in the background.
We should configure PDF.js to only load the parts of a PDF file that are required to render the currently visible page and nothing else. In many cases, users will view only a subset of the pages, not the entire document.
Linearize/optimize PDF files for range requests
PDF is a complex file format and not every PDF file is structured in a way that lends itself well to range requests. We could consider optimizing PDF files for range requests during ingestion (at least for files that are converted from a different file type to PDF).
The text was updated successfully, but these errors were encountered: