rgrove / rawgit

Served files from raw.githubusercontent.com, but with the correct content types. No longer actively developed.
https://rawgit.com
MIT License
2.39k stars 488 forks source link

Optimize Cache-Control headers #177

Closed mattbrundage closed 6 years ago

mattbrundage commented 6 years ago

The FAQ states that "The CDN caches files permanently based on their path."

Based on this info, may I recommend setting a far-future cache-control header of 1 year. Currently, the max-age of assets served from cdn.rawgit.com is 86400 (24 hours), which is very low.

Also, consider the "Cache-Control: immutable" directive. In browsers that support it, it saves the client from having to perform revalidation.

rgrove commented 6 years ago

Hi Matt. You're apparently looking at a CDN URL that's using the master branch. RawGit only caches master branch URLs for 24 hours and doesn't mark them as immutable, because the contents of the master branch are likely to change and too many people were using master branch CDN URLs and then asking why the CDN never picked up their changes.

The same FAQ answer you're referring to also advises using a tag or commit ref rather than a branch in the URL. If you do this, you'll see that the CDN does serve a far-future cache-control header with the immutable directive.

mattbrundage commented 6 years ago

Good deal. Thanks.