What categories are the build cache of static site generators divided into, and can the cache expiration be set to never expire?

📅 2026-10-11 👁️ 15

What types of build caches are divided in static site generators, can the cache expiration be set to never expire? The conclusion is that taking Hugo as an example of this type of static generator, it divides the intermediate products into multiple types of caches according to their purposes during the build period, each of which can be set to a separate directory and retention time; if the retention time is set to a negative value, which is -1 in the convention, these entries will never expire. However, never expiring does not mean not cleaning up, as there is another garbage collection switch responsible for deleting unused old files during the build. Whether to extend the retention or clean up regularly depends on the rhythm of the site.

What types of caches are divided during the build period

Static generators render sites by first calculating a batch of reusable intermediate results, such as processed resources, compressed images, and downloaded theme modules. The configuration page of the Hugo official documentation categorizes these results into seven types of file caches: resources, resource queries, image processing, miscellaneous derived data, module git version information, module queries, and module content itself.

They are separated because each category has different volume and update frequency: image processing takes up the most space and is the most time-consuming, while the module content rarely changes after download. After categorization, operations can individually adjust directories or retention time for a particular category without having to clear a large area in a generic manner.

Cache Type What is roughly cached Settable items (dir/maxAge)
Resources assets Reusable resources after processing Set individually
Images images Scaling and cropping and other image results Set individually
Resource query getresource Resource search result by name Set individually
Modules modules Download theme or module Set individually
Git information modulegitinfo Module version library information Set individually
Module query modulequeries Search results for available modules Set individually
Miscellaneous misc Other derived data Set individually

Can the directory and retention time be adjusted separately

Each type of cache can use dir to specify the directory it falls into, and use maxAge to specify how long to retain, both independently. By default, they are concentrated in a unified cache directory. If a particular type is especially large or needs to be placed on a faster disk, it can be assigned a separate directory for easier mounting and backup.

The retention time determines how long a cache item stays on the disk. Most categories have a shorter default duration unless explicitly set, the documentation mentions that some caches expire on a scale of 24 hours; setting the value to a negative number, as agreed upon by -1, means that these entries never expire and will not disappear automatically over time. This only describes the retention time and is different from the cleaning switch below.

The cost of never expiring and the cleaning switch

After setting the retention time to a negative value, the occupation only increases and does not decrease until new content is continuously written. For sites with frequent construction and a large number of images, it is easy to expand the cache directory and slow down the backup for a long time, so it should be set according to capacity and rhythm, and cannot be set to the bottom without considering the situation.

The real cleaning of leftovers is the garbage collection switch during the construction period, which deletes the old cache files that are no longer in use during the construction. The objects it acts on are the leftovers that are no longer referenced. It complements the expiration by time, one manages how long to keep, and the other manages to clear the unused ones. Only by working together can it speed up and not fill up the disk.

When the construction slows down, first confirm where the cache falls.

When building becomes significantly slower, the first thing to do is not to rush to delete the cache, but to confirm where the slowness is in terms of category and which directory the cache falls into. It is best to first check the configuration of various dir settings and the actual size of the corresponding directory on the disk: if the main part is image processing and there is enough space, extend its retention time even to make it never expire, so that reconstruction can hit as much as possible; if the directory is already very large and the disk is also tight, then clean up regularly by version or rely on the garbage collection switch to delete old residues.

It should be clarified as a prerequisite: the above is for static sites generated during the build period. Systems like AnQiCMS based on Go language do not go through the build period to generate, but organize pages only when requests come, so there is no layer of build cache, retention time, and cleaning switch. The focus of operation and maintenance is on runtime and deployment, and the troubleshooting approach is different from static generators, and the cache directory system cannot be directly transferred over.

Common questions

Q: If the cache validity period is set to -1, will it never fill up the disk?Not at all. -1 only means that the entry will not be cleared due to timeout, but the continuous addition of content will still accumulate usage. The recycling depends on the garbage collection switch during construction, which clears the residual data that is no longer referenced, and it is a separate mechanism from the retention period.

Can only a directory be set for one of the seven types of caches?Yes. The dir and maxAge for each type are independently configured, and it is a common practice to place image processing on a high-speed disk separately, while the rest remain at the default settings, without needing to move the whole thing.

Q: Some caches expire by default after 24 hours, will they be discarded without reuse?The default expiration only affects categories that have not been explicitly adjusted. For caches that are slow to process and infrequently updated, you can extend the retention time individually or set it to -1 for subsequent hits; worry about accumulation and rely on garbage collection switches for regular cleaning.

Q: Does the dynamic system need to be configured according to this?No. AnQiCMS is a dynamic content system based on the Go language, pages are assembled at request time, not generated during the build period, so there is no such build cache and retention time, the focus of operation and maintenance is on runtime and deployment level.

Related articles

The default template has been upgraded to a major version along with the front-end framework, what styles and scripts in the site need to be changed?

The default template follows the upgrade of the front-end framework, and the changes are concentrated in three aspects: class structure, plugin dependencies, and initialization writing. Taking the update records of similar systems as an example, when the front-end framework upgrades to a larger version, two dependency libraries are removed, and when the back-end script library upgrades across versions, it also needs to synchronize the style correction of the interface components, and the custom templates of the site need to be回归 in the same way.

2026-10-11

How should the announcement that bypasses the input filter be arranged from the version a few years ago to the present?

The announcement bypassing the input filters lists the affected versions from versions years ago to the current branch, with the rating only given to medium. The disposal order of old sites should be arranged according to upgradability and exposure: first confirm whether it can be upgraded to the fixed version, then decide whether to narrow the entry or plan for migration, and clarify the responsibilities of the filtering layer and the escaping layer.

2026-10-11

The security announcement for the form module only covers two version ranges, should the site be upgraded first or disable the submission function first?

A security announcement for a form module provides two affected ranges and two fixed versions. The order of handling should be decided by the branch and exposure surface: if it can be upgraded to the corresponding fixed version immediately, it should be upgraded first. If the upgrade needs to be scheduled, consider temporarily closing the external submission entry and record the scope of closure and recovery conditions.

2026-10-11

The open-source content system posted a security patch preview days in advance, what should the operation and maintenance team do in these days?

The security patch preview only provides the time window and risk level, without giving details of the vulnerability. The preparations that can be made in these days are therefore very specific: confirm whether the module is within the scope, back up the data and static files, practice the upgrade path on the copy, prepare the checklist for the release day, and reserve time for rollback and review.

2026-10-11

The AI gateway makes web search into an interface to provide externally, and the content retrieved by the model is more than a list of whose.

When web search is made into an interface on the gateway, the content being retrieved goes through an additional checklist on the gateway side. Cloudflare connected the search capability to the AI gateway at the beginning of October 2026 and required the results to include the source address of the content retrieved. For content sites, discoverability is no longer solely determined by search engine crawling, and the site description file and crawling exclusion rules need to be in place in the chain.

2026-10-11

After reviewing dozens of generative optimization studies, it is said that changing the engine technique is not valid, how can the site's practice prove itself

A review of research covering the years 2023 to 2026 reviewed dozens of optimization experiments for generative engines, concluding that thematic relevance and contextual position are the most reproducible, general techniques are difficult to migrate to different engines, and no technique has been proven to have stable, long-term, cross-platform effects. The content site needs to use is to replace others' conclusions with self-site comparative verification.

2026-10-11

An interface method that can carry hundreds of password combinations in a single request, why can't it prevent login failure lock?

In the early legacy remote procedure call interface, there is a batch method that can pack hundreds of username-password combinations into a minimal number of HTTP requests, making the login lock based on the number of failures ineffective; the same mechanism can also be used for amplification attacks. Whether to retain such entries and at what level to intercept is an inevitable judgment when the interface is closed.

2026-10-11

Cross-domain isolation requires setting two response headers at the same time, why third-party images and scripts suddenly do not load

To enable cross-origin isolation, you need to set two response headers at the same time, one to control which cross-origin resources the local document can access, and one to manage the window reference relationships. After setting it to require explicit permission, if third-party images and scripts in the page do not carry the cross-origin mark, they will fail to load. The troubleshooting should consider both the source marker and the release of the resource itself.

2026-10-11