Cache is not invalidated when changing view

I deployed a test platform using the default docker swarm that came with the project template. Varnish is enabled and works.

The problem is, when a editor changes the view for a folder (or any other content type) the cache is not invalidated and old view is not shown until the user force refreshes.

Is there any way to automatically invalidate the varnish cache on view change? I was unable to find a configuration for it.

There also is an existing topic for it: Content view not purged in varnish cache when switching view , but due to its age and lack of answer i felt it was appropriate to open a new one.

1 Like

Purges are done on modification, moving, removing and workflow. In plone.app.content, changing a view:

calls setLayout:

that finally call setDefaultPage that... reindex the object but don't call notify(ObjectModifiedEvent(obj)) with the modified event. I think it will work if you do so.

Thank you very much for your answer! Unfortunately I do not quite understand. Should I notify the ObjectModifiedEventHandlers myself with the notify method? And if so, where should I do that? Can I myself listen for a view change?

I think you've to test if changing Products/CMFDynamicViewFTI/browserdefault.py works. If it works, you can make a PR. Locally, you can do an add-on that overwrite the setLayout method.