How to update a remote resource?

I am unable to see the updates of a remote XML feed in a Hugo project.

Does --ignoreCache apply to remote resources?

Is there some other way?

Yes.

See the getresource key.

One other way is also to use cache busting techniques such as adding a version identifier to the URL, e.g. https://myfeed?v=32

You can probably be clever with the above and do:

{{ $url := printf "https://myfeed?v=%d" now.YearDay }}

But since YearDay returns 1-365 that may not be optimal if you never flush the cache …

1 Like

Thank you very much for the cache busting idea.

I modified the code snippet to: {{ $url := printf "https://myfeed?v=%d" now.Unix }} and it works great.

P.S. I would rather not use --ignoreCache

That looks very fine grained … This would maybe be better:

{{ $url := printf "https://myfeed?v=%d-%d" now.Year now.YearDay }}

Me neither, but I highly recommend adding a sensible file cache config. It helps clean out stale files on your disk, too.

When I have more time, I will look into the cache config so that out-of-date cached XML files can be deleted manually to cleanup the disk.

The reason why I don’t plan to use the --ignoreCache CLI flag is because I will be depending heavily on the generated cache for a Hugo blog project I am setting up tonight.

The workflow will look like this:

Send an email => Generate a feed => Retrieve the feed in Hugo and generate Taxonomy Pages for each entry in the feed via an Archetype that will be getting deleted and then re-created whenever a Build is triggered (basically this is a modified version of Regis Philibert’s technique).

It certainly looks like I have a long night ahead of me, because on top of the above I also need to develop a functioning prototype of the front end by tomorrow.

[Anyway if I manage to pull this through I might consider restarting blogging myself]

I did it naturally. Hm…took me around six hours…

But anyway. I DIT IT. :+1:

I am now able to convert an email to an RSS entry and then update Hugo via a Netlify web hook.

The above cache busting technique was exactly what I needed.

So I am a very happy camper.

P.S. Somebody was right when they said that the new remote resources just opened up a whole new set of possibilities for users to shoot themselves in the foot. However it’s worth it.

1 Like

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