magento-cache-clean icon indicating copy to clipboard operation
magento-cache-clean copied to clipboard

Frontend Cache-Clean [F] does not seem to clear static content

Open kolaente opened this issue 2 years ago • 6 comments

When pressing F, the files in pub/static/frontend are still present.

kolaente avatar May 20 '22 08:05 kolaente

Thanks for opening the issue @kolaente - I must have broken it at one point in time!

Vinai avatar May 20 '22 13:05 Vinai

I am unable to reproduce the issue.
When I press F the files in pub/static/frontend are gone, only the directories remain.


My steps to reproduce on my current dev instance:

  1. Reload the homepage after clearing static view files.
  2. Then, list all files and symlinks (because I am running in deploy mode developer).
$ find pub/static/frontend/ -type f -or -type l
pub/static/frontend/Hyva/default/de_CH/Magewirephp_Magewire/js/livewire.js
pub/static/frontend/Hyva/default/de_CH/Magewirephp_Magewire/js/livewire.js.map
pub/static/frontend/Hyva/default/de_CH/css/styles.css
pub/static/frontend/Hyva/default/de_CH/Hyva_Theme/js/alpine.min.js
pub/static/frontend/Hyva/default/de_CH/Hyva_Theme/js/alpine.min.js.map
pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/owlcarousel/owl.carousel.min.css
pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/styles.css
pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/mgz_bootstrap.css
pub/static/frontend/Hyva/default/de_CH/Magezon_Core/css/fontawesome5.css
pub/static/frontend/Hyva/default/de_CH/Magento_Theme/favicon.ico
pub/static/frontend/Hyva/default/de_CH/images/hero-2x.jpg
pub/static/frontend/Hyva/default/de_CH/images/hyva-logo.svg
pub/static/frontend/Hyva/default/de_CH/images/logo.svg
  1. Press F in the cache-watcher
  2. Finally, list all files and symlinks, again
$ find pub/static/frontend/ -type f -or -type

Result: no files are left.

Vinai avatar May 20 '22 13:05 Vinai

Please let me know if I am missing a step when reproducing the issue.

Vinai avatar May 20 '22 13:05 Vinai

I just (partially) bumped into this issue. In general, [F] clears static content files for me. However, it seems to not clear any broken symlinks. So if there is a broken symlink under pub/static, this broken symlink will not be removed, which may lead to issues.

Use case:

  1. Override a file in your theme.
  2. Open the page, so that the symlink for this file is created.
  3. Remove the file from your theme, because you do not want to override it any more.
  4. Press [F].

Expected: The broken symlink of the old overridden file is removed. Actual: The broken symlink is not removed, so that Magento is missing a file in the frontend.

sprankhub avatar Nov 08 '22 09:11 sprankhub

That's interesting. I wonder why the broken symlinks are not removed. If I recall correctly, this function should remove them, too...

Vinai avatar Nov 08 '22 11:11 Vinai

I just bumped into this again. I have no idea about ClojureScript, but I figured the files are unlinked via the rm function. Could it be that the following exists? check returns false for broken symlinks, so that they are not unlinked?

https://github.com/mage2tv/magento-cache-clean/blob/d95b541d6f7bca9098f604f1b2b951bac29954c3/src/file/system.cljs#L75

sprankhub avatar Dec 02 '22 13:12 sprankhub