30

I have a Jekyll bootstrap based blog hosted on Github pages.

My problem is: Every time I change something on my web page, I have to forcefully reload the page (CTRL + R) to see the changes.

Jekyll or my browser does not seem to realize that there is a newer version available to send out.

How can I configure Jekyll to better handle this?

5
  • 2
    Chances are that Github Pages is sending out aggressive caching headers, telling the browser not to check for an updated version of the resource until a certain time.
    – Charles
    Mar 9, 2012 at 17:19
  • So there is no possibility to circumvent this with Github Pages? Mar 9, 2012 at 17:22
  • You'll need to ask them about their caching practices.
    – Charles
    Mar 10, 2012 at 0:44
  • Hey @SebastianHoitz did you solve this? I am facing a similar issue.
    – n_x_l
    Sep 16, 2012 at 16:17
  • I've also asked them about this, but to no avail. Sep 22, 2012 at 22:43

3 Answers 3

6

There are a couple of jekyl plugins to handle assets cache busting.

https://github.com/ixti/jekyll-assets/

http://matthodan.com/2012/11/22/jekyll-asset-pipeline.html

I tried jekyll-assets and it's pretty nice as it manage all kind of assets with an md5 version number.

Before I use to append a string to my css links at compilation time.

<link href="{{ ASSET_PATH }}/css/global.css?{{ site.time | date:'%Y%m%d%U%H%N%S' }}" rel="stylesheet">
2
  • Question is not about assets, it's about html cache. Jan 9, 2013 at 12:03
  • yop but this plugin add cache busting strings, that's why I answered here. my bad :) Jan 9, 2013 at 16:10
3

You can add these meta tags to your html to disable browser caching for your pages.

<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
-1

If you want to bypass the cache on static resources you could change the name of the file each time you push it. This will make the browser get the new resource since it won't know anything about a file with a new name.

For example:

Old file name: project.css New file name: projectv01.css

Or whatever you would like.

1
  • 1
    The referring page would have to be renamed as well which would break the user experience completely. Instead of index.html it would have to be index01.html :). Otherwise the cache will serve the index.html that points to project.css rather than projectv01.css. Using javascript to add ?cache=random to every content url is A solution.. but a horrible bad solution.
    – whardier
    Dec 9, 2012 at 22:02

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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