sorry-app / status-bar

Display your Sorry™ status updates on your website and helpdesk.
https://www.sorryapp.com/notifications/
Apache License 2.0
10 stars 4 forks source link

No cache-control headers set #47

Closed tvb closed 6 years ago

tvb commented 6 years ago

Hi,

I am getting a F rating in webpagetest.org because of the following:

FAILED - (No max-age or expires) - https://code.sorryapp.com/status-bar/4.latest/status-bar.min.js
FAILED - (No max-age or expires) - https://code.sorryapp.com/status-bar/4.latest/status-bar.min.css

can you guys please fix this?

SirRawlins commented 6 years ago

@tvb absolutely. I'll look at getting some cache control headers added to our assets hosts. I'll drop you an update when we've had the chance to get that done.

tvb commented 6 years ago

@SirRawlins got an update for me?

SirRawlins commented 6 years ago

@tvb hey Tristan, I've added some cache headers, they're fairly conservative but should improve your grading. Did you want to re-test and let me know what it makes of them?

tvb commented 6 years ago

Huge improvement there!

screen shot 2018-06-04 at 10 12 50

Some notes though:

Leverage browser caching of static assets: 82/100

...
FAILED - (17.5 minutes) - https://code.sorryapp.com/status-bar/4.latest/status-bar.min.css
WARNING - (60.0 minutes) - https://code.sorryapp.com/status-bar/4.latest/status-bar.min.js
WARNING - (60.0 minutes) - https://code.sorryapp.com/status-bar/4.latest/fonts/Icons/status-bar-icons.woff
...
SirRawlins commented 6 years ago

@tvb awesome, I'm so pleased to hear it. 🎉

The other notes here are to be expected, ideally we'd like to set much longer cache headers than 60 minutes, however, it makes rolling out changes and fixes slower, so for now, we find a compromise at 1 hour.

Really appreciate your help and suggestions with this.

tvb commented 6 years ago

@SirRawlins Why would that be an issue? You can set the proper cache-control headers and just invalidate the cache at the CloudFront side whenever you push an update ci/cd style 🤓

SirRawlins commented 6 years ago

@tvb for sure! Our build process does invalidate Cloudfront, but the cache-control headers are also used by the browser to cache a copy locally, which we are not able to invalidate.

At least that's my understanding, but I may be wrong. 🤓

tvb commented 6 years ago

I'm not sure because CloudFront will present you with a Miss the first time after an invalidation and so it serves it to the client. I'm pretty sure the client follows but we should test it..

SirRawlins commented 6 years ago

@tvb interesting! I'll reopen this issue and try to test this, see if I can confirm.

SirRawlins commented 6 years ago

@tvb I did a little experimentation on this today, and it seems my initial hunch was right, setting the cache-control header means the asset is cached in two locations.

1) In Cloudfront, which we're able to purge. 2) In the Browser, which we are NOT able to purge.

The only way for the browser to pickup new versions is to wait until the content has expired, and then grab the latest version from the CDN.

So for now I think we'll keep the short expiry window. I have some potential work-arounds, but I think they'll wait for another day.

tvb commented 6 years ago

Roger!