Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Asset Etag is useless and invalid #274

Open
AtomicNibble opened this issue May 19, 2020 · 4 comments
Open

Asset Etag is useless and invalid #274

AtomicNibble opened this issue May 19, 2020 · 4 comments

Comments

@AtomicNibble
Copy link

The ETag sent back for assets (js,img,..) changes for every response making it useless.

https://github.com/gobuffalo/buffalo/blob/0ffd608c63439be1fc033ad7e48430528c96d2bc/route_mappings.go#L111-L115

This is because packd just returns the time you opened the file.
https://github.com/gobuffalo/packd/blob/128b5da43f114d0f9af8b4bba549b02e3496dfa8/file.go#L115

The ETag is also of invalid format and should be quoted as per RFC https://tools.ietf.org/html/rfc7232#section-2.3

Suggest the ETag is just removed as the info to make a sensible ETag is not avaliable and a very long max-age is already sent back.

@paganotoni
Copy link
Member

Hey @AtomicNibble 👋, Thanks for reporting this. This seems only to happen in development mode due to a packr issue. I confirmed that this does not happen on compiled binaries where I see the ETag persist across requests .

@paganotoni
Copy link
Member

I'm moving this one to the packr repository.

@paganotoni paganotoni transferred this issue from gobuffalo/buffalo May 24, 2020
@AtomicNibble
Copy link
Author

Thanks for investigating, does that mean the ETag will change after every deploy tho?

@paganotoni
Copy link
Member

That's a good question. I think you're right. Here is what I did to prove it:

buffalo build -o bin/app # builds the app
bin/app # starts the app

# Requesting asset
curl -s -o /dev/null -D - http://localhost:3000/assets/application.463d2be36c4e069c72b5.css
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Content-Length: 443539
Content-Type: text/css; charset=utf-8
Etag: 16120c74bb30a368
Last-Modified: Sun, 24 May 2020 19:08:33 GMT
Date: Sun, 24 May 2020 19:08:33 GMT

buffalo build -o bin/app # builds the app
bin/app # starts the app

curl -s -o /dev/null -D - http://localhost:3000/assets/application.463d2be36c4e069c72b5.css
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Content-Length: 443539
Content-Type: text/css; charset=utf-8
Etag: 16120c9736764ce0
Last-Modified: Sun, 24 May 2020 19:11:02 GMT
Date: Sun, 24 May 2020 19:11:02 GMT

Notice how Etag changes without any modification to the file. I think Packr is using the compilation time as the last modification time of the file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants