I updated to 0.127.0 to play around with live reloading from a remote resource and thought I would try to get output from an RSS feed displayed on my site and updating automatically. This worked great when running my site with “hugo server” but updates stopped happening on my site when I built it to serve with nginx. I think this is because I may be lacking understanding in some core concepts.
I created a ttrsspull.html file under layouts/shortcodes to parse the output of ttrss XML:
and I thought the magic to make it work was in the config.toml file:
[httpcache]
[httpcache.cache]
[httpcache.cache.for]
includes = ['https://path/to/xml']
[[httpcache.polls]]
low = '1s'
high = '30s'
[httpcache.polls.for]
includes = ['https://path/to/xml']
but I am missing something as it does not update when the RSS XML updates after I build the site (but it does work in my dev environment using hugo server). Can someone point me in the right direction on what I should be configuring?
Got it. I was assuming that the release notes in Release v0.127.0 · gohugoio/hugo · GitHub pointed to new functionality that would allow more dynamic content on a Hugo site. I assume, then, the new 127 features are used for creating templated pages from remote data. If so, what would be the benefit of live reloading (trying to get more understanding of what the art of the possible is).
Live reloading occurs when running the development server. Live reloading does occur once you’ve built the site.
My limited understanding of the HTTP Cache when used in production: we pull the remote file if something has changed (based on the eTag in the response header) regardless of the maxAge of the file cache. Note that the max age of the file cache can be set in site configuration, or as an optional argument for each resources.GetRemote call.
The benefit is that we don’t have to pull, for example, a 100MB remote data file unless it has changed.
We have some terms that’s used about these things: Live reload, partial rebuilds …
Live reload on changes is a browser thing, and used with hugo server.
Mostly a development/content editing feature, where you get instant refreshes of changes in the browser.
But we also have
hugo -w
Which starts a Hugo watcher that rebuilds on changes.
A not uncommon setup would be to have hugo -w running on the web server and publish directly to where the files are hosted.
This would also support the new HTTP cache/remote polling.
Also, you would typically also pull/mount the source files on that web server. A related tip if you mount via e.g. NFS or Samba (neither, I believe, support OS level events on changes), start Hugo with the --poll (file polling):