After using Google's PageSpeed Insights for my site [ http://flashmallach.github.com ] the biggest error I'm still coming up w/ is leveraging browser caching. I found some solutions that suggest using a .htaccess file to do this, however GitHub pages apparently do not support them.

Is there another way I can pull this off ?

  • 3
    From: Tekkub (GitHub Staff) Subject: leverage browser caching on github pages // That's not possible currently, but we might add it in the future. Thanks for the suggestion. – flash Jun 7 '12 at 2:41

A review of the github Pages Documentation would suggest that this level of configuration is not made available to github Pages users.

You can contact github Pages Support to see if this level of configurability will be made available (or if they can configure for you), however, I suspect that you will find a more expedient solution by hosting your images on a service which supports the configuration you would like to use.



By the far, the more efficient way to increase your score is to use a free content delivery network to serve your site. I recommend the free version of CloudFlare because of its simplicity. There are a few reasons for this:

  • The CDN will automatically minify your HTML, CSS and JavaScript. Google PageSpeed requires this.

  • GitHub Pages by default places a caching header of 10 minutes on all resources. Google will throw a “Leverage browser caching” error for this. You can override this from the CDN. On CloudFlare, I did this by creating a Page Rule (in addition to the general caching option) that sets the Cache level on everything to a minimum of 8 days (Google’s recommendation). I am not using the Rocket Loader option.

  • The CDN will automatically Gzip elements, such as SVG’s (even though they’re served from GitHub)

  • Setting up the CDN will by far increase your PageSpeed results, but it may take up to 24 hours for your CDN setting changes to propagate (you won’t see them reflected in Google’s results immediately.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.