Skip to content

Add a hugo module version query JSON cache #14417

@bep

Description

@bep

This relates to #14416 when using e.g. version = "<v3.0.0" in your module import. This is very useful, but since Go needs to recalculate the correct version on every Hugo build, it's slow.

Go has a API to take in a cached JSON response, so this should be relatively simple to implement.And well worth it.

I suspect that people would want to control the expiry of this, so I suggest we make it its own cache, so I suggest:

  • A new file cache named modulequeries with:
    • dir = ':cacheDir/modulequeries'
    • maxAge = '24h'

This means that in downloadModuleVersion:

  • Create a key using path + version
  • Check file cache, if it exists, pass the filename as -reuse argument to download.
  • Store the returned JSON in the file cache.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions