I'm experiencing an interesting and odd situation with entity (field value) caching.

I'm using hook_ENTITY_TYPE_storage_load() to set the value of a field when nodes of a certain type are loaded. Per the documentation these alterations will be cached, which is what I want.

But also I want to invalidate/clear that cache at a different point in code. Per this answer to "How do I invalidate the cache of an entity?" I'm calling


(where $changed is the array of node IDs). This works for me locally: the storage load hook runs and I see my expected (newly updated, not cached) field value as loaded in the hook.

But on an Acquia Cloud environment, I don't see the updated value until I run the Admin Toolbar Tools' menu's "Flush plugins cache" option. Looking at the code for that link's controller callback, I see it running a CachedDiscoveryClearerInterface instance's method clearCachedDefinitions().

I don't think this is really an Acquia issue; just that our Acquia env happens to employ additional/different caching than on my local env. The confusing part is why cached plugin information would have any effect on the caching of an entity / its field value. (Inspecting the cache_discovery database table, I see a bunch of structural things like field definitions and element info, in addition to plugin information.)

I'm hoping someone can explain what's being cached and why. For reference, I am checking my field value in a field widget on a node edit form - not the rendered node output.

  • The plugin discovery cache clearer goes through all plugin managers which can clear as much as they see fit. Did you try to invalidate the cache tags of the nodes node:[id], too? Could be that in production more caching is enabled which is using this tag. – 4k4 Feb 8 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.