It's both, and can run in several different modes.
In dynamic mode, you are correct that the HTML files act as a cache.
In static mode, the on-demand layer (and any related hooks in the web server) are turned off, with all the pages being pre-generated.
There is also a hybrid mode, where the access log (and content store) is scraped for updates and they're integrated into the static HTML on a schedule.
Each of these has its own advantages and drawbacks in terms of security, accessibility, performance, and convenience.
In dynamic mode, you are correct that the HTML files act as a cache.
In static mode, the on-demand layer (and any related hooks in the web server) are turned off, with all the pages being pre-generated.
There is also a hybrid mode, where the access log (and content store) is scraped for updates and they're integrated into the static HTML on a schedule.
Each of these has its own advantages and drawbacks in terms of security, accessibility, performance, and convenience.