On physically moving a file through the FAL API, the cache of affected pages is not cleared
When a file is moved through the FAL API, the cache of all pages that link that file must be cleared.
Signals that must be used:
Updated by Philipp Gampe over 6 years ago
The cache must not be cleared automatically, because the file might be used on many pages, even with "insert record" and "show contents of this page", etc. This would be a huge complexity and can potentially kill the server, both for clearing all those caches and for regenerating the caches later on.
Instead, the caching framework should ask the caching framework to clear all cache with the tag sys_file_<uid>:
/** @var CacheManager $cacheManager */ $cacheManager = $this->getCacheManager(); $cacheManager->flushCachesInGroupByTag('pages', 'sys_file_' . $uid);
See \TYPO3\CMS\Core\DataHandling\DataHandler::processClearCacheQueue() [bottom of the function].
The integrator/developer of the site need to make sure to tag all pages that should be cleared automatically. This way he has full control over the performance impact.
Updated by Lorenz Ulrich over 6 years ago
Comment from Helmut Hummel in Gerrit:
The proposed CacheService works very low level, which is likely to cause troubles when changing internals. It also works kind of "backwards" by looking at the usages of files in the moment they are changed/moved Instead I would propose to correctly set cache tags "file_usage_<idOfFile>" for the page once the page is rendered and e.g. publicUrl is called for a file. When doing so, we can just call ->flushByTag("file_usage_<idOfFile>") when a file is changed
Updated by Jigal van Hemert about 6 years ago
- Priority changed from Should have to Must have
The same effect can be seen by:
- overwriting a file in the Filelist module
- overwriting a file with other methods and running the Scheduler task to update the FAL index
With the pre-FAL behaviour we could explain to editors that placing an image on a page creates a copy of the original image. With FAL this was over and the advantages were clear. Editors wouldn't understand that they would have to manually track down where an image is used and clear caches (an image used in a record would even be more complicated, because it might be necessary to clear the caches of the pages where the record is used).
Updated by Susanne Moog about 1 year ago
- Status changed from On Hold to Closed
For completenes sake: TYPO3 does not clear caches automatically and will only do so when and if proper caching for all kinds of content is implemented. As that is a long way of and this ticket is a task, I'm going to close this now as the whole topic probably needs an own initiative. (Also because the requirements for different projects might differ a lot, see comments above about insert records for example).
For those needing a more immediate solution to that problem, please take a look at https://extensions.typo3.org/extension/cacheopt which provides the requested feature via hooks as far as I can see.