# CACHE headers and busting technique in jekyll

**URL:** https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816
**Category:** Help
**Created:** [May 21, 2018, 10:59am UTC](https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816 "2018-05-21T10:59:07Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tejasshetty](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tejasshetty](https://talk.jekyllrb.com/u/tejasshetty)
#### Post date: [May 21, 2018, 10:59am UTC](https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816/1 "2018-05-21T10:59:07Z")

</div>

is there a way to set cache headers and use cache busting techniques in jekyll?

---

<div class="post-metadata">

### Author: ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)
#### Post date: [May 21, 2018, 4:26pm UTC](https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816/2 "2018-05-21T16:26:09Z")

</div>

I’ve seen cache busting techniques that use gulp - and would highly recommend using gulp with jekyll to handle as much as possible as it is much quicker.

---

<div class="post-metadata">

### Author: ![chrisfinazzo](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/chrisfinazzo/32/561_2.png) [@chrisfinazzo](https://talk.jekyllrb.com/u/chrisfinazzo)
#### Post date: [May 22, 2018, 10:34pm UTC](https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816/3 "2018-05-22T22:34:03Z")

</div>

It’s simple, but I presume something like [this](https://ethanmarcotte.com/wrote/stupid-jekyll-tricks/) might do the job.

---

<div class="post-metadata">

### Author: ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)
#### Post date: [May 23, 2018, 12:35am UTC](https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816/4 "2018-05-23T00:35:18Z")

</div>

That’s an interesting idea, I use S3 to host so I don’t have control like you do.

Did give me the idea that I could just add a querystring to the css/js files that adds the site.date to it, and that would cache bust I think, but would change every time I build rather than every time I change the css/js.

I like your idea of using a site variable, easy enough to remember to change that when needed which is rare for me at the moment.

The Gulp way that I saw used a data file and some sort of Gulp magic to check the date modified and then change the version number if needed in the data file via Gulp.

---

<div class="post-metadata">

### Author: ![chrisfinazzo](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/chrisfinazzo/32/561_2.png) [@chrisfinazzo](https://talk.jekyllrb.com/u/chrisfinazzo)
#### Post date: [May 23, 2018, 1:27am UTC](https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816/5 "2018-05-23T01:27:34Z")

</div>

> [@rdyar](#):
>
> Did give me the idea that I could just add a querystring to the css/js files that adds the site.date to it, and that would cache bust I think, but would change every time I build rather than every time I change the css/js.

When I did this for my service worker (and Minima’s), I used one of the Liquid date functions, so no explicit querystring required. It’s a bit verbose and caching is still my enemy, but it works well enough.

---

<div class="post-metadata">

### Author: ![jerrygoyal](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/jerrygoyal/32/2114_2.png) [@jerrygoyal](https://talk.jekyllrb.com/u/jerrygoyal)
#### Post date: [December 19, 2019, 7:53pm UTC](https://talk.jekyllrb.com/t/cache-headers-and-busting-technique-in-jekyll/1816/6 "2019-12-19T19:53:03Z")

</div>

it’s really simple:  
just append query string to the asset file with jekyll timestamp.  
`<script src="../assets/js/main.js?v={{ site.time | date:'%s' }}"></script>`
