Skip to content
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

SPA caching is incorrectly applied to index.html #258

Closed
evangoer opened this issue Aug 22, 2017 · 9 comments
Closed

SPA caching is incorrectly applied to index.html #258

evangoer opened this issue Aug 22, 2017 · 9 comments

Comments

@evangoer
Copy link

Per #209: in SPA mode, serve should be serving up assets with the specified cache value, but ./index.html is special-cased to have no cache. Instead, serve appears to be serving up all files with the specified --cache value.

$ ./node_modules/.bin/serve --version
6.0.6
$ ./node_modules/.bin/serve --single --cache 12345678000


$ curl -I localhost:5000/
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Accept-Ranges: bytes
Cache-Control: public, max-age=12345678
Last-Modified: Tue, 22 Aug 2017 17:33:37 GMT
ETag: W/"c-15e0b01bd68"
Content-Length: 12
Vary: Accept-Encoding
Date: Tue, 22 Aug 2017 17:57:09 GMT
Connection: keep-alive
$ curl -I localhost:5000/index.js
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: public, max-age=12345678
Last-Modified: Tue, 22 Aug 2017 17:33:50 GMT
ETag: W/"13-15e0b01f030"
Content-Type: application/javascript
Content-Length: 19
Vary: Accept-Encoding
Date: Tue, 22 Aug 2017 17:57:23 GMT
Connection: keep-alive
@evangoer
Copy link
Author

evangoer commented Aug 22, 2017

However, if you hit a path that isn't the physical index.html file or an asset file, the index.html contents do get returned with a max-age of 0:

$ curl -I localhost:5000/no-physical-file-at-this-path
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: public, max-age=0
Last-Modified: Tue, 22 Aug 2017 17:33:37 GMT
ETag: W/"c-15e0b01bd68"
Content-Type: text/html; charset=UTF-8
Content-Length: 12
Vary: Accept-Encoding
Date: Tue, 22 Aug 2017 18:01:57 GMT
Connection: keep-alive

@leo
Copy link
Contributor

leo commented Aug 22, 2017

Have you read this?

@evangoer
Copy link
Author

Yes, I have. And I've read the commit diffs for #209. Unfortunately, there's a bug.

$ curl -I localhost:5000/
Cache-Control: public, max-age=12345678

@evangoer
Copy link
Author

For clarity, here are the three cases side-by-side:

$ curl -I localhost:5000/index.js
Cache-Control: public, max-age=12345678                 // correct
$ curl -I localhost:5000/no-physical-file-at-this-path
Cache-Control: public, max-age=0                        // correct (though probably should be no-cache?)
$ curl -I localhost:5000/
Cache-Control: public, max-age=12345678                 // incorrect

@leo
Copy link
Contributor

leo commented Aug 22, 2017

Oh. Are you using the -s flag?

@evangoer
Copy link
Author

Yup, running with -s.

@ericf
Copy link

ericf commented Sep 11, 2017

I'm curious if there's any update on this issue?

@leo
Copy link
Contributor

leo commented Sep 11, 2017

Seems like we need to fix it! We're not correctly applying the right caching values.

@leo
Copy link
Contributor

leo commented Oct 16, 2017

Fixed in #269 - will go out once #274 is merged!

@leo leo closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants