cache control headers for serving pages offline by service worker #60087
Replies: 3 comments
|
Hello, Unfortunately, returning a max-age=0 value for I do not have a good or simple workaround for you. We don't support custom headers at the moment and I have no ETA to share around when this feature will be available. You could eventually try to put Cloudflare in front of your site and customize headers there. It would come with its own set of pros and cons. |
|
I solved this by having the service worker substitute the header I want,
for each file it retrieves from the cache. The cached files, technically,
have the default headers, but after the initial load, the browser never
sees them because the service worker does the substitution at the point of
retrieval. The service worker priority is to use cached files first. Now,
my app will reload correctly, even when completely offline.
…On Wed, Jul 5, 2023 at 1:21 PM Yoann Chaudet ***@***.***> wrote:
Hello,
Unfortunately, returning a max-age=0 value for Cache-Control would mean
disabling browser caching. This is not something we are willing to do.
I do not have a workaround for you. We don't support custom headers at the
moment and I have no ETA to share around when this feature will be
available.
—
Reply to this email directly, view it on GitHub
<#60087 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHX7DFNBEUXYI3KTVP75ZTXOXED5ANCNFSM6AAAAAAZ6I2IC4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
8828 NE Schuyler St, Portland OR 97220
503-253-8100
I'm not on instant-annoy text/phone/email, so please give me a day or so
lead time.
|
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Select Topic Area
Question
Body
I have written an app for plant species data collection, which works offline using a service worker. It functions well, except every now and then, in a remote location with no trace of connectivity, it glitches and won't reload. I asked ChatGPT how to force reload of the index page. Most of what ChatGPT replied was familiar, except a step to "add cache control headers". It said to add the following headers to my server configuration:
Cache-Control: public, max-age=0
Since these are pages hosted on GitHub, do I have access to any such server configuration? If so, how?
The link to my app is below. It's optimized for mobile. If you try it in a desktop browser, I would suggest an incognito window so its cache and service worker get cleared when you close.
https://rickshory.github.io/vegnab-webapp/
All reactions