Task #60898

On physically moving a file through the FAL API, the cache of affected pages is not cleared

Added by Lorenz Ulrich almost 6 years ago. Updated 2 months ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2014-08-11
Due date:
% Done:

0%

TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
easy
Sprint Focus:

Description

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:

  • postFileMove
  • postFileRename
  • postFileReplace
  • postFolderMove
  • postFolderRename

History

#1 Updated by Gerrit Code Review almost 6 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/32098

#2 Updated by Ingo Schmitt over 5 years ago

  • Category changed from Frontend to File Abstraction Layer (FAL)
  • Sprint Focus set to On Location Sprint

#3 Updated by Philipp Gampe over 5 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.

#4 Updated by Philipp Gampe over 5 years ago

  • Complexity set to easy

#5 Updated by Lorenz Ulrich over 5 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

#6 Updated by Mathias Schreiber over 5 years ago

  • Sprint Focus deleted (On Location Sprint)

#7 Updated by Mathias Schreiber over 5 years ago

Results of the discussion at the FAL sprint:
Before we can handle this in a meaningful way the Content Elements need to properly tag the page cache.

If this functionality is in place, we can then clear by tags.

#8 Updated by Mathias Schreiber over 5 years ago

  • Status changed from Under Review to Accepted

#9 Updated by Jigal van Hemert about 5 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).

#10 Updated by DMK E-BUSINESS GmbH about 4 years ago

Hi,

we got the same problem, hoping for a solution. The bug is accepted but there seems to be no progress since almost one year.

Can a fix still be expected?

#11 Updated by Susanne Moog about 1 year ago

  • Tracker changed from Bug to Task
  • Status changed from Accepted to On Hold

As stated before this can only be fixed after sensible tagging of Content Elements has been introduced.

#12 Updated by Susanne Moog 2 months 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.

Also available in: Atom PDF