Replies: 3 comments 1 reply
-
Answer: GitHub Pages and HTTP Range Requests with GzipGitHub Pages uses a CDN (typically backed by Fastly) that automatically applies gzip compression to certain file types, even for What's happening?
This inconsistency leads to the error: Has GitHub Pages behavior changed?Yes, GitHub Pages and its underlying CDN may update behavior periodically, including how it handles caching and compression. If this setup previously worked, it’s possible a recent change now forces gzip encoding on Workarounds1. Self-host the fileHost the SQLite file on a server where you can fully control HTTP headers, including disabling gzip for specific routes. 2. Manually set the file lengthIf you know the exact size of the SQLite file (in bytes), you can pass it directly in the {
fileSize: 1234567 // exact byte size of the SQLite file
} |
Beta Was this translation helpful? Give feedback.
-
Hello, Thank you for providing detailed context and headers—this is a great question and an increasingly relevant scenario for client-side applications relying on byte-accurate file delivery. Recent Changes & GitHub Pages BehaviorGitHub Pages serves static assets behind a CDN, which may apply optimizations like transparent gzip compression. In recent months, there have been updates on how HEAD and GET/Range requests are processed, particularly regarding content-encoding. If you notice This discrepancy—compressed on HEAD but uncompressed on Range—means the Workarounds & Recommendations1. Disable Compression for Database FilesGitHub Pages/CDN does not allow end-user configuration to disable compression for specific file types. All files may be subject to gzip if the CDN considers it appropriate, especially for 2. Supply File Length in Client ConfigAs a workaround, sql.js-httpvfs allows you to explicitly provide the file length in your config object: {
//...
fileLength: 123456 // Actual byte size of your SQLite file
} You can determine this by checking the uncompressed file size locally or via a build step. This bypasses the need for HEAD content-length accuracy. 3. Serve From a Custom Domain or Different HostIf you need stricter control over HTTP headers (including compression), consider using an alternative static hosting provider (e.g., Cloudflare Pages, Netlify, AWS S3 with static hosting) where you can configure headers to ensure no compression is applied to database files. 4. File Suffix WorkaroundsSome users have reported success by serving files with uncommon extensions (e.g., renaming Summary
If you have further questions or need help with alternative hosting setups or automation for file size detection, feel free to ask! |
Beta Was this translation helpful? Give feedback.
-
I'm encountering a related issue with gzip encoding on HTTP Range (206) responses, specific to Firefox. Minimal reproduction of the issue here, which only fails on the combination of GitHub Pages server + Firefox browser: https://github.com/bdon/ghpages-firefox-range-bug |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
Hello,
I have been using GitHub Pages to serve SQLite database files for a client-side app with sql.js-httpvfs, which requires HTTP Range requests to read parts of the database file.
Until recently, this setup worked correctly. However, now the sql.js-httpvfs worker throws an error:
Length of the file not known. It must either be supplied in the config or given by the HTTP server.
Upon inspecting the HTTP response headers, I see that HEAD requests respond with content-encoding: gzip. According to sql.js-httpvfs, this breaks range requests because the server returns compressed data on HEAD but serves uncompressed data on range requests, making the byte length calculation incorrect.
Example response headers from a HEAD request:
content-encoding: gzip accept-ranges: bytes content-length: 1288
This behavior causes sql.js-httpvfs to fail when trying to read the file size and ranges properly.
Could you please confirm if there has been a recent change in how GitHub Pages serves static files or handles gzip encoding on HEAD and Range requests? Is there a recommended workaround to properly serve files that need range requests without gzip interfering?
Thank you very much for your help!
Beta Was this translation helpful? Give feedback.
All reactions