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.

CommentFileSizeAuthor
#3 2987596-3.patch17.06 KBsamuel.mortenson

Comments

samuel.mortenson created an issue. See original summary.

samuel.mortenson’s picture

Assigned: Unassigned » samuel.mortenson
samuel.mortenson’s picture

Status: Active » Needs review
StatusFileSize
new17.06 KB

That 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.

  • samuel.mortenson authored ad84ba3 on 8.x-1.x
    Issue #2987596 by samuel.mortenson: Use cache tags to determine what...
samuel.mortenson’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.