Problem/Motivation
Currently the "tome:static" command always does a full rebuild of your site. This makes sense when Tome is built from scratch, but if a persistent editing environment exists we can take advantage of cache tags to determine what pages need generated.
Proposed resolution
When cache tags are invalidated, regenerate pages that had those tags.
Remaining tasks
Determine what this looks like. Should the "tome:static" command do partial builds by default, or do users expect pages to be exported as they edit content in the UI? If the latter, what exactly happens on a large site when someone rebuilds cache? Do we queue all the pages that need re-built?
User interface changes
None.
API changes
N/A
Data model changes
None.
Comments
Comment #2
samuel.mortensonComment #3
samuel.mortensonThat was hard. Using cache tags I added a list of files that each static path is dependent on, with a SHA1 hash of their current contents. If a file is deleted, or its contents do not match, the page is rebuilt.
You can test this out by running
drush tome:static --partial. I didn't make this the default behavior because this behavior may confuse new users - for example if I changed theme code, ran a "drush cr", then ran "drush tome:static --partial", no pages would change since no source files (config/content) changed.Views are also tricky - If you add a node and there's a view of recent nodes on the homepage, the cache tags on the home page don't change (edits/deletes to existing nodes shown in the view, or changes to the view work fine). To accommodate this I added a simple "tome_static_cache_exclude" setting, which users can use to always exclude specific paths from static cache. I would imagine that a lot of sites would set this to their homepage, but for advanced use cases you can also pass a regular expression.
Comment #5
samuel.mortenson