# Content adapters: caching

**URL:** <https://discourse.gohugo.io/t/content-adapters-caching/50115>\
**Category:** support\
**Tags:** content-adapters\
**Created:** [June 1, 2024, 10:54pm UTC](https://discourse.gohugo.io/t/content-adapters-caching/50115 "2024-06-01T22:54:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![demonax](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/demonax/32/24222_2.png) [@demonax](https://discourse.gohugo.io/u/demonax)\
**Post date:** [June 1, 2024, 10:54pm UTC](https://discourse.gohugo.io/t/content-adapters-caching/50115/1 "2024-06-01T22:54:01Z")

</div>

Following the reference example in the [docs](https://gohugo.io/content-management/content-adapters/#example) I’ve built a Hugo site using content from a Wordpress site via the REST API.

This works as intended on the first run. Both `hugo server` and `hugo` download the remote data and build/serve as expected.

On later rebuilds, no posts added to the WP site since the initial build are added. This seems to be a caching issue. The command `hugo server --ignoreCache` will fetch the updated posts.

As I recall this is done to avoid hammering an API on rebuilds, which is a sane choice. However, I’m not sure how to trigger a rebuild to fetch updates without using the `--ignoreCache` flag.

Is using the flag the expected behavior, or is there something I’m missing?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 1, 2024, 11:15pm UTC](https://discourse.gohugo.io/t/content-adapters-caching/50115/2 "2024-06-01T23:15:31Z")

</div>

You can control how long the data is cached:  
[https://gohugo.io/getting-started/configuration/#configure-file-caches](https://gohugo.io/getting-started/configuration/#configure-file-caches)

For example, to evict the cache after 10 minutes:

```plaintext
[caches.getresource]
dir = ':cacheDir/:project'
maxAge = '10m'

```

You can change the cache location if you want to inspect and easily clear it. For example, to place the files in the resources directory in the root of your project:

```plaintext
[caches.getresource]
dir = ':resourceDir'
maxAge = '10m'

```

---

<div class="post-metadata">

**Author:** ![demonax](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/demonax/32/24222_2.png) [@demonax](https://discourse.gohugo.io/u/demonax)\
**Post date:** [June 1, 2024, 11:38pm UTC](https://discourse.gohugo.io/t/content-adapters-caching/50115/3 "2024-06-01T23:38:17Z")

</div>

Got it, thanks. I wasn’t sure if the config cache settings applied here.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [June 2, 2024, 1:59pm UTC](https://discourse.gohugo.io/t/content-adapters-caching/50115/4 "2024-06-02T13:59:03Z")

</div>

You can also set a unique cache expiration for each `resources.GetRemote` call:  
[https://gohugo.io/functions/resources/getremote/#caching](https://gohugo.io/functions/resources/getremote/#caching)

So you could have a global cache expiration of `168h` (7 days), but expire calls to `example.org/foo.json` every hour.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [June 4, 2024, 1:59pm UTC](https://discourse.gohugo.io/t/content-adapters-caching/50115/5 "2024-06-04T13:59:27Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
