From 0286144b14ef7ce2a943999fc616c3c24be83c57 Mon Sep 17 00:00:00 2001 From: tdro Date: Sat, 28 May 2022 17:53:31 -0400 Subject: config: Set caches --- config.json | 26 ++++++++++++++++++++++++++ config.toml | 26 ++++++++++++++++++++++++++ config.yaml | 20 ++++++++++++++++++++ content/canory/messages/cache.md | 35 +++++++++++++++++++++++++++++++++++ content/canory/messages/gates.md | 2 +- content/canory/messages/hugo.md | 2 +- 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 content/canory/messages/cache.md diff --git a/config.json b/config.json index 3e6db0c..ad4a10f 100644 --- a/config.json +++ b/config.json @@ -245,6 +245,32 @@ "html" ] }, + "caches": { + "assets": { + "dir": ":resourceDir/_gen", + "maxAge": -1 + }, + "images": { + "dir": ":resourceDir/_gen", + "maxAge": -1 + }, + "getcsv": { + "dir": ":resourceDir/caches", + "maxAge": "12h" + }, + "getjson": { + "dir": ":resourceDir/caches", + "maxAge": "12h" + }, + "getresource": { + "dir": ":resourceDir/caches", + "maxAge": "12h" + }, + "modules": { + "dir": ":resourceDir/caches", + "maxAge": -1 + } + }, "module": { "mounts": [ { diff --git a/config.toml b/config.toml index 2375ee2..fdfeccc 100644 --- a/config.toml +++ b/config.toml @@ -174,6 +174,32 @@ enableRobotsTXT = true term = ["html", "rss"] page = ["html"] +[caches] + + [caches.assets] + dir = ":resourceDir/_gen" + maxAge = -1 + + [caches.images] + dir = ":resourceDir/_gen" + maxAge = -1 + + [caches.getcsv] + dir = ":resourceDir/caches" + maxAge = "12h" + + [caches.getjson] + dir = ":resourceDir/caches" + maxAge = "12h" + + [caches.getresource] + dir = ":resourceDir/caches" + maxAge = "12h" + + [caches.modules] + dir = ":resourceDir/caches" + maxAge = -1 + [module] [[module.mounts]] diff --git a/config.yaml b/config.yaml index a71f1d5..a297ded 100644 --- a/config.yaml +++ b/config.yaml @@ -168,6 +168,26 @@ outputs: page: - html +caches: + assets: + dir: :resourceDir/_gen + maxAge: -1 + images: + dir: :resourceDir/_gen + maxAge: -1 + getcsv: + dir: :resourceDir/caches + maxAge: 12h + getjson: + dir: :resourceDir/caches + maxAge: 12h + getresource: + dir: :resourceDir/caches + maxAge: 12h + modules: + dir: :resourceDir/caches + maxAge: -1 + module: mounts: - source: content diff --git a/content/canory/messages/cache.md b/content/canory/messages/cache.md new file mode 100644 index 0000000..cb408be --- /dev/null +++ b/content/canory/messages/cache.md @@ -0,0 +1,35 @@ ++++ +date = "2022-02-27T20:18:43+00:00" +lastmod = "2022-02-27T20:18:43+00:00" +tags = [ "docs", "cache" ] +author = "canory" ++++ + +Resource abuse is not good --- cache responsibly. In the `hugo` configuration +file (config.yaml, config.json, config.toml) set the cache expiry time. The +default is `12h` (12 hours) for remote fetches and `-1` (forever) for assets, +images, and modules. The time scales are seconds (`s`), minutes (`m`), and hours +(`h`). Turn off a cache by setting a max age of `0`. + +```yaml {options="hl_lines=9-17",caption="Caching Options"} +--- +caches: + assets: + dir: :resourceDir/_gen + maxAge: -1 + images: + dir: :resourceDir/_gen + maxAge: -1 + getcsv: + dir: :resourceDir/caches + maxAge: 12h + getjson: + dir: :resourceDir/caches + maxAge: 12h + getresource: + dir: :resourceDir/caches + maxAge: 12h + modules: + dir: :resourceDir/caches + maxAge: -1 +``` diff --git a/content/canory/messages/gates.md b/content/canory/messages/gates.md index d264b0b..ecb1aa9 100644 --- a/content/canory/messages/gates.md +++ b/content/canory/messages/gates.md @@ -7,7 +7,7 @@ author = "canory" Satisfy the keepers of the gate by officially verifying ownership of your property, uh, website. Put the verification code from their web mastery tools -into your `hugo` configuration file (`config.yaml`, `config.json`, +into the `hugo` configuration file (`config.yaml`, `config.json`, `config.toml`). ```yaml diff --git a/content/canory/messages/hugo.md b/content/canory/messages/hugo.md index d8c1710..63698d6 100644 --- a/content/canory/messages/hugo.md +++ b/content/canory/messages/hugo.md @@ -1,7 +1,7 @@ +++ date = "2022-03-26T04:45:51+00:00" lastmod = "2022-03-29T22:55:17+00:00" -tags = [ "docs", "hugo" ] +tags = [ "docs", "hugo" ] author = "canory" +++ -- cgit v1.2.3