-
Notifications
You must be signed in to change notification settings - Fork 820
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
Usage of serviceworkers to cache resources #1340
Comments
Feedback/thoughts from @saru-tora would be very welcome! |
@krausest Any thoughts on this? In my opinion it basically invalidates the "total kilobyte weight" metric, but if it is desired then a readme note similar to "preload the glyphicon" might be useful. |
I had hoped I fixed it accidentally by running lighthouse only once anymore, but it still reports 142 KBs. But it seems like it doesn't count them. Will investigate... |
Hmmmm - I tried if I can log the response sizes in the server (then maybe we could measure both uncompressed and compressed). But I failed both for fastify and for the old express server to do so. /keyed/anansi/index.html 2385 I have no idea why the service worker returns a size of 0 (with express-response-size). But I get the same effect for fastify with the onSend hook (Response is an empty string though it's actually 1739 bytes). |
Yes, it was indeed a 304. Seems like chrome caches the service worker even when Application > Storage > Clear site data is invoked. I tried three approaches to calculate the size of the frameworks:
Please let me know if you have any suggestions about step 1+2. The results of step 3 looks like that:
I decided to filter out all /css resources. The size is smaller than the one reported by chrome, since the headers are missing. I tried to emulate the headers, but some headers (like Date) are not present so it didn't match exactly either. There's a new callback http://localhost:8080/getSize that returns The size is reset whenever index.html is called. The idea is to fetch this information from the benchmark driver and report both data in the results table. This would also be a good solution for #1377, #1041 The fastify server code suffered from this feature. I only got it working with a hack in a onSend-hook. Looking forward to hearing you opinions! Does that sound like a reasonable approach? |
Here's a first preview. I'm looking forward to getting feedback. The numbers are in kBs (I'll add that info to the table). If you want to check here's how to do:
Anything surprising or something that sounds fishy in the table? |
Thanks! misojs looks a bit weird when comparing the total kilobyte weight with the new numbers, any idea as to why? I'd also think that if the total kilobyte weight metric is kept around it'd be good for some clarification as to what it is meant to represent, since it is neither a completely cold load or a load with a warmed cache. |
Here's the output for misojs:
When comparing with the network tab this looks ok. I have no idea why lighthouse doesn't show that difference. I plan to remove the total kilobytes from the table. |
The proposed solution didn't get negative feedback so I'm closing this issue. |
I posted this as a comment in #1217 but I figured it deserved its own issue.
I was looking at the size comparisons and it seems like anansi uses a service-worker to precache most of the app.
This makes it seem like the full size of it is just the ~1kb for the loader that loads the serviceworker, but on a fresh load there is another ~250kb loaded.
Here is a comparison of the startup metrics with the serviceworker and without:
It seems like anansi is the only testsuite using serviceworkers, at least in code within this repo.
I'm not sure if there is any guidelines on how to use serviceworkers in this test, but if it is not measured properly (i.e the full, non-cached load) then the size comparison becomes pretty useless since every framework will be reporting a size for something like
navigator.serviceWorker.register('sw.js');
and no framework or app code.I'm a bit biased since I care about the size metrics for my own framework, but my suggestion is either clearing the serviceworkers before each test run, disallow using serviceworkers or disabling serviceworkers in the tests entirely.
The text was updated successfully, but these errors were encountered: