# Leverage browser caching

**URL:** https://talk.jekyllrb.com/t/leverage-browser-caching/138
**Category:** Help
**Created:** [February 16, 2017, 12:54am UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138 "2017-02-16T00:54:44Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![diklein](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/diklein/32/60_2.png) [@diklein](https://talk.jekyllrb.com/u/diklein)
#### Post date: [February 16, 2017, 12:54am UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138/1 "2017-02-16T00:54:44Z")

</div>

Google PageSpeed recommends that I “leverage browser caching” for my CSS by “setting a maximum age in the HTTP headers.” How does one do this with Jekyll?

---

<div class="post-metadata">

### Author: ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)
#### Post date: [February 16, 2017, 1:15am UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138/2 "2017-02-16T01:15:28Z")

</div>

The good news is there are a bunch of options and resources available to you since what you want to do isn’t specific to Jekyll.

Depending on the server type you’re using to host your site this will vary, but if you’re using Apache you can set caching headers via a `.htaccess` file.

[HTML5 Boilerplate](https://html5boilerplate.com/) has a really [good one that is heavily commented](https://github.com/h5bp/html5-boilerplate/blob/master/dist/.htaccess#L835-L934) that walks through all kinds of good things you’ll want to enable for improved performance (gzip compression, etc.) and security.

---

<div class="post-metadata">

### Author: ![diklein](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/diklein/32/60_2.png) [@diklein](https://talk.jekyllrb.com/u/diklein)
#### Post date: [February 16, 2017, 1:49am UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138/3 "2017-02-16T01:49:33Z")

</div>

Thanks! Now I’m trying to figure out how to do this without .htaccess since I’m using nginx.

---

<div class="post-metadata">

### Author: ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)
#### Post date: [February 16, 2017, 3:44am UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138/4 "2017-02-16T03:44:43Z")

</div>

They also have server configs for nginx

> <https://github.com/h5bp/server-configs-nginx/blob/master/h5bp/location/expires.conf>

> <https://github.com/h5bp/server-configs-nginx/blob/master/nginx.conf>

---

<div class="post-metadata">

### Author: ![diklein](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/diklein/32/60_2.png) [@diklein](https://talk.jekyllrb.com/u/diklein)
#### Post date: [February 16, 2017, 6:20pm UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138/5 "2017-02-16T18:20:06Z")

</div>

@mmistakes Thanks! I also found this:

> <https://gist.github.com/adamwalz/8108694>
>
> There are more than three files. show original

---

<div class="post-metadata">

### Author: ![thedatasleuth](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/thedatasleuth/32/1230_2.png) [@thedatasleuth](https://talk.jekyllrb.com/u/thedatasleuth)
#### Post date: [September 3, 2018, 2:10pm UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138/6 "2018-09-03T14:10:14Z")

</div>

Hi - I’m trying to resolve the same issue you were working on - did you ever figure it out? I see this github that you posted - is it just a matter of copying these files over to the root directory of my jekyll blog? Thank you in advance!

---

<div class="post-metadata">

### Author: ![thedatasleuth](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/thedatasleuth/32/1230_2.png) [@thedatasleuth](https://talk.jekyllrb.com/u/thedatasleuth)
#### Post date: [September 3, 2018, 2:17pm UTC](https://talk.jekyllrb.com/t/leverage-browser-caching/138/7 "2018-09-03T14:17:39Z")

</div>

Do I just paste these files in the root of my jekyll blog?
