304s for unmodified files
it would be great if requests for unmodified files got a 304 status code, it would make serving static websites much faster :).
I've tried to make it work in https://github.com/zeit/micro-list/commit/6bd503184a968f1cbbb5b43f2d326d34f3b9d55a (it should, but it sadly doesn't, I think). Will take another stab at it soon!
nice! I may have spotted a bug (I'll comment on the commit) but I also could be wrong :)
Sadly, that wasn't the problem. I've tried a few things, but nothing seems to work. The main problem is probably that the files (except the assets of micro-list itself) don't even get saved to the cache. Maybe @rauchg can take a stab at this?
All in all, the request doesn't contain the "if-modified-since" header (except when it's an asset, like I said).
@leo you must supply an ETag first with every file, which could be a very quick hashing function (like crc32) concatenated file mtime
Should be fixed in v0.5.0!
Hey,
Just wondering if it's possible to get more infos on how caching really works.
Let's suppose I build my frontend at t1 and produce 2 files vendor.js and app.js, and serve them on now-serve. As I would use it as a CDN, I want caching to kick in. Now let's supposed I build frontend at t2 and produce the same 2 files that I redeploy with now-serve.
On second deploy, vendor.js is exactly the same as before (because my app libs did not change), but app.js is different (using hash compare is enought).
Will the headers be correctly set to enforce that the user see immediately the changes to app.js, and get a 304 for vendor.js ?
@rauchg in my example, the vendor.js of the 2nd deployment has been rebuilt (so I guess it has different mtime), but content is exactly the same as before and I want a 304 instead of a cache miss. Is it possible with now-serve, or would it be possible to make it an option?
according to my test it seems it's actually working like I want. The modified time of a file is not updated if the content is exactly the same as before as far as I see
Edit: no, not working
Opened another issue because 304 does not work for me: https://github.com/zeit/list/issues/40