-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[✨] Automatic simple 404 responses for file requests #6302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
where are you deploying qwik to? |
looks like google cloud run if you deploy all built files in /build into the same bucket location behind a cdn then this will also fix the problem. in the ssr.entry you can set base to that bucket url so base: "https://my-cdn.com/my-path-to-bucket/build/" |
not quite sure I'm understanding you :) Everything works as expected, files do exist and are pulled correctly. Our problem (and probably everyone's problem) is that if you make a request for a non-existing JS file (maybe due to caching) that it delivers the 300kb custom JS file instead of a few bytes:
The ethos of qwik is that everything is fast and optimised out of the box and developers don't accidentally fall into performance pitfalls, so delivering your custom 300kb 404 page and causing 30mb of wasteful requests is something that developers have to understand and manually fix. |
ok the solution was setting cloudflare (that is in front of cloud-run) anything with /build to be cache forever |
@PatrickJS although it wouldn't hurt to have the static file serving for the assets base serve simple 404s |
yup I agree |
I have a draft PR here if anyone wants to take over the PR. Basically remake it and check that everything works. Possible add a test |
let me try? |
Signed-off-by: Okiki <hey@okikio.dev>
@JerryWu1234 we have a PR for this one |
Is your feature request related to a problem?
I'm not sure why, but every now and again I'll see lots of 404 requests from the service worker for JS files from a previous deployment. I'm guessing the list of files are cached and re-requested despite no longer existing and then they're probably cleaned up by the service-worker as no longer existing.
We're using a custom 404.tsx page which is generated at build time, includes the layout and is around 300kb. When we released a new version I saw around 100x requests for JS that no longer existed and that basically means the browser downloaded 30mb needlessly, slowing down the loading of the page dramatically in poor network conditions.
Describe the solution you'd like
For static file requests, you don't need a pretty 404 page and a smaller response could be delivered. I'm not sure if there's something that can be fixed in the service-worker to not make all of these requests for old JS files that no longer exist.
Describe alternatives you've considered
We're currently doing this inside our entry.cloud.run.tsx to manually fix it:
Additional context
We're using qwik insights (need to remove until it works for us) and we're currently using an awful prefetchStrategy as it fixes the delays for us when switching pages. We noticed a considerable improve to the user experience when just loading everything and I had no choice but to merge it, even though it's painful. I'm not sure if this is the reason for loading JS that no longer exists but I doubt it:
The text was updated successfully, but these errors were encountered: