fastboot-app-server icon indicating copy to clipboard operation
fastboot-app-server copied to clipboard

Fix cache

Open mhluska opened this issue 7 years ago • 0 comments

In my case the cache wasn't working because res.send was never being called (thus cache.put was never called).

After changing the implementation to use res.write and res.end and getting it to work, I noticed that the cache can only be used for caching text/html resources because the res.send() call for a cache hit will overwrite the content type, regardless of what type it is storing (css, js etc). So you have to be careful to have a cache implementation that rejects a promise during the fetch call if the content type is any besides text/html.

Also, the cache middleware has to go before gzip otherwise gzip doesn't work.

mhluska avatar Aug 29 '18 12:08 mhluska