akejolin / snowpack-plugin-content-hash

A small snowpack plugin which will add a content hash to all your imports paths on build command.
MIT License
8 stars 4 forks source link

dev server #3

Open cucar opened 3 years ago

cucar commented 3 years ago

Would it be possible to use this for dev server? I'd like to do content hashing for the files so that page refresh doesn't take too long. Currently the dev server serves files with no cache header and keeps responding back with 304s.

Thank you, Cagdas

akejolin commented 3 years ago

This plugin is build to run after snowpack is done and has finished all tasks. To make it work in dev I may need to look on another hook because i am not sure if the optimize hook runs in dev.

About the 304, can´t you use the disable cache mode in Chrome? @cucar Then the browser is forced to go for a 200 response.

image

cucar commented 3 years ago

Thank you for the quick response. The problem I'm having is that even with 304s, it takes a long time for pages to refresh in dev mode. I have about 600 files loaded for the page, so even when each file takes little with 304 response, it takes 3-6 seconds for the page to refresh. I'm trying to optimize it. The browser should not even need to request the unchanged files. When I make a change to a file, all the names of the files up to the index.js needs to change but not the others. That way, when a file changes in dev mode, only that file and its parents in import tree are refreshed on the browser. The goal is to speed up page refresh during development. Let me know if that makes sense. I can try to explain further with examples.

Thank you, Cagdas