Skip to content

Caching Jekyll _site files not working #26816

Caching Jekyll _site files not working #26816
Mar 21, 2021 · 2 answers

I’m trying to cache my _site files when I build my Jekyll site using this:

  # Use GitHub Actions' cache to cache site on servers
  - uses: actions/cache@v2
    with:
      path: _site
      key: ${{ runner.os }}-site-${{ hashFiles('**/index.html') }}
      restore-keys: |
        ${{ runner.os }}-site-
github.com

datapolitical/chrisfnicholson.github.io/blob/1be6c49ebfa3861869820e4f2ef18f4a449b48b2/.github/workflows/build-jekyll.yml

name: Build and Deploy to Github Pages

on:
push:
branches:
- main # Here source code branch is master, it could be other branch
workflow_dispatch:

jobs:
build_and_deploy:
runs-on: ubuntu-20.04
steps:
- name: 'Wait for status checks'
id: waitforstatuschecks
uses: "WyriHaximus/github-action-wait-for-status@v1.2"
with:
ignoreActions: build_and_deploy
checkInterval: 10
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

This file has been truncated. show original

Unfortunately when it runs I get:

Received 22 of 22 (100.0%), 0.0 MBs/sec
Cache Size: ~0 MB (22 B).

Not clear what’s going wrong. Is the path incorrect?

I don’t think that Jekyll can utilize what it previously generated if you cache the _site folder. You should cache the folder .jekyll-cache and if it exists also the file .jekyll-metadata (haven’t seen it on Windows, but on Linux). Maybe cache the _site in addition, not sure if it makes a difference.

Replies

2 suggested answers

I don’t think that Jekyll can utilize what it previously generated if you cache the _site folder. You should cache the folder .jekyll-cache and if it exists also the file .jekyll-metadata (haven’t seen it on Windows, but on Linux). Maybe cache the _site in addition, not sure if it makes a difference.

0 replies
Answer selected

Thanks! Yea was able to eventually get this working and it’s much better!

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants