Debian Codegraph @

docs/content/en/configuration/caches.md

raw
1 ---
2 title: Configure file caches
3 linkTitle: Caches
4 description: Configure file caches.
5 categories: []
6 keywords: []
7 ---
8
9 This is the default configuration:
10
11 {{< code-toggle config=caches />}}
12
13 ## Purpose
14
15 Hugo uses file caches to store data on disk, avoiding repeated operations within the same build and persisting data from one build to the next.
16
17 `assets`
18 : Caches processed CSS and Sass resources.
19
20 `getresource`
21 : Caches files fetched from remote URLs via the [`resources.GetRemote`][] function.
22
23 `images`
24 : Caches processed images.
25
26 `misc`
27 : Caches miscellaneous data.
28
29 `modulegitinfo`
30 : Caches Git information for modules.
31
32 `modulequeries`
33 : Caches the results of module resolution queries.
34
35 `modules`
36 : Caches downloaded modules.
37
38 ## Keys
39
40 `dir`
41 : (`string`) The absolute file system path where Hugo stores the cached files. You can begin the path with the `:cacheDir` or `:resourceDir` [tokens](#tokens) to anchor the cache to specific system or project locations.
42
43 `maxAge`
44 : (`string`) The duration a cached entry remains valid before being evicted, expressed as a [duration](g). A value of `0` disables the cache for that key, and a value of `-1` means the cache entry never expires. Default is `-1`.
45
46 ## Tokens
47
48 `:cacheDir`
49 : (`string`) The designated cache directory. See [details][cachedir].
50
51 `:project`
52 : (`string`) The base directory name of the current Hugo project. This ensures isolated file caches for each project, preventing the `hugo build --gc` command from affecting other projects on the same machine.
53
54 `:resourceDir`
55 : (`string`) The designated directory for caching output from [asset pipelines](g). See [details][resourcedir].
56
57 ## Garbage collection
58
59 As you modify your site or change your configuration, cached files from previous builds may remain on disk, consuming unnecessary space. Use the `hugo build --gc` command to remove these expired or unused entries from the file cache.
60
61 [`resources.GetRemote`]: /functions/resources/getremote/
62 [cachedir]: /configuration/all/#cachedir
63 [resourcedir]: /configuration/all/#resourcedir