Introducing a content cache tag "Workspace_*"

I am currently working on the layered workspaces and workflow support for Neos. When you start working with nested workspaces (that is, for example user-john -> some-workspace -> live) you’ll experience problems with content caching, because by now we did not consider the workspace for which content was rendered and can’t flush the cache for a particular workspace (well, as a far as I know at least).

When you rebase your user workspace onto a different workspace, you need to reload the document shown in the content module. For example switching from user-john -> some-workspace -> live to user-john -> some-other-workspace -> live essentially means that all content rendered for user-john must be discarded and re-rendered.

My solution consists in tagging content cache entries with an additional Workspace_ tag (for example Workspace_user-john). And now comes my question: which TypoScript prototypes should define such a tag?

We have TYPO3.TypoScript:GlobalCacheIdentifiers for rendering entry identifiers, but nothing similar for tags, right? On the other hand, is it really necessary to tag all content with Workspace_? Or just documents?

Any thoughts are highly appreciated …

the question is… Tag oder Identifier? If we generate a unique identifier from the workspace chain and add that as global identifier it could work automatically I think? Otherwise we have to introduce a global tag I guess, because everything cached could contain a node from a different workspace. Well could not will, that’s the hard part.

The workspace is already considered in the identifier because it is part of the node context path. But yes, it makes sense to include the workspace chain (or a hash thereof) into the entry identifier, because if you switch between base workspaces, you can take advantage of the previously cached version.

Some train of thought:

What if each content cache segment (that is, TypoScript prototype derived from Document or Content) was tagged with the node’s workspace? If we flush the cache for a specific workspace, entries depending (embedding) that flushed cache entry would be flushed as well. But of course we can’t be sure that a TypoScript object whose content is cached in the Foo workspace doesn’t contain any content from the Bar workspace – for example by some content repository queries.

It looks like selectively flushing individual content cache entries on a base workspace change won’t get us anywhere. What sounds reasonable to me is the following solution:

  1. entry identifiers of all content cache entries must contain the workspace chain (hash), for example sha1('user-john/some-workspace/live')
  2. all content cache entries are also tagged with the every workspace being part of the current chain, except for “live”: for example, user-john and some-workspace (= 2 tags) for a single entry
  3. if user john changes the base workspace (from some-workspace to some-other-workspace) Neos does not have to flush any cache, it re-uses possibly existing cache entries
  4. if a workspace is published or deleted, Neos flushes all content cache entries by the tag Workspace_some-workspace

Yep sounds good and roughly follows what I had in mind as well.