FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
190 stars 229 forks source link

Why disabling asset cache on backend sessions? #1798

Closed tastendruecker closed 12 months ago

tastendruecker commented 1 year ago

https://github.com/FluidTYPO3/vhs/blob/c962d0dce84ad9b1cb2091ba716befab98be34ec/Classes/Service/AssetService.php#L350

Is it really necessary to re-generate all temporary asset files when a back-end user is logged in? This approach leads eventually to a heavy flooding of the typo3temp directory with asset files. Would it be possible to get rid of this condition?

Thanks in advance and best regards Sven

NamelessCoder commented 12 months ago

The condition is necessary - but is somewhat outdated (should rather be a check for frontend.preview aspect).

The purpose is to ensure that a new and different cached file is generated if a backend user is previewing changes. If the condition was not there, such previewing would potentially break because of missing assets.

Normally this shouldn't cause a flooding problem: only one cached file should be generated for each combination of assets. So let's say that your backend user adds a content element that contains one or more assets, this would cause a single new variant to be created (the one for the cached version + the one for the not-yet-published version).

It is however quite true that VHS would leave orhpaned asset files - since VHS doesn't actually delete the file when a cache expires, it just sets file modification time to zero. This is to make sure that files are physically there so no risk is posed if the pages cache was not flushed at the same time - the physical files will exist and be loaded correctly in FE, but will be overwritten next time the page cache content is written.

Since 114f764a4aec9b22946e962ac978744f454eb632 you can use the "Remove temporary files" function to delete all VHS assets.