Caching implications for nicetime twig function


I found and like the twig function nicetime to be used with my blog item template.

However, I guess that since this value needs to be evaluated on every page request (since it changes from “1 minute ago” to “1 hour ago” to “1 day ago” etc.) it will have impact on caching.

My assumption is that any page that uses this function is actually never cached because of this.

Can anyone explain the caching implications / penalties for using this function? Can I safely use it or should I avoid it?


@metbril As far as I know, ‘nicetime’ will not have any impact on caching.

Grav does not cache the resulting HTML file, which will indeed change over time. Instead, Grav caches the php file generated when compiling a Twig template.

Try the following:

  • Search for ‘nicetime’ in the cache folder.
    This will only return a cached PHP file generated by Twig compilation.
  • Search for the current result of ‘nicetime’ (e.g. ‘5 days ago’) in the cache folder.
    You won’t find it…


I will do this when I have access to the filesystem and can do a ‘grep’.