# Using git revision as cache key

**URL:** <https://zola.discourse.group/t/using-git-revision-as-cache-key/1971>\
**Category:** Support\
**Created:** [December 17, 2023, 2:49pm UTC](https://zola.discourse.group/t/using-git-revision-as-cache-key/1971 "2023-12-17T14:49:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdown](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@cdown](https://zola.discourse.group/u/cdown)\
**Post date:** [December 17, 2023, 2:49pm UTC](https://zola.discourse.group/t/using-git-revision-as-cache-key/1971/1 "2023-12-17T14:49:26Z")

</div>

Hi there, I’m considering migrating [https://chrisdown.name](https://chrisdown.name) from Jekyll to Zola, since it’s the last thing I really use in Ruby. Most plugins are easily able to be rewritten as shortcodes. One I am not sure about the best way to go about is this one:

```auto
module GitRevPlugin
  class GitRev < Jekyll::Generator
    safe true
    def generate(site)
      site.data['gitrev'] = %x(git rev-parse --short HEAD).strip
    end
  end
end

```

I then use this as a cache key later to make sure the version of the CSS is the same as the page being displayed:

```auto
<link rel="stylesheet" href="/css/style.css?{{ site.data["gitrev"] }}">

```

I see a couple of ways I could do this in Zola, but both seem less than ideal since they both rely on an external build script:

1. Dynamically generate a shortcode with a build script before running Zola, embedding the current git revision.
2. Put the current git revision in an environment variable using a build script, and then query that from a shortcode.

Is there some way to avoid having to create an external build script for this? Thanks!

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [December 17, 2023, 9:40pm UTC](https://zola.discourse.group/t/using-git-revision-as-cache-key/1971/2 "2023-12-17T21:40:33Z")

</div>

It’s not available right now. It could be added but it’s something we would want to add automatically on every page render I think, rather than on a function call? See [Feature request: build datetime · Issue #2375 · getzola/zola · GitHub](https://github.com/getzola/zola/issues/2375) for something related
