a-r-m-i-n / min

TYPO3 CMS extension "min" - Compressed CSS, JS and HTML output for TYPO3
7 stars 7 forks source link

[Bug] Asset compression (CSS/JS) is generated with every page view #26

Closed bjoern-reichert closed 2 months ago

bjoern-reichert commented 3 months ago

Hello,

on a website that is larger and where an external crawler monitors the site, I analyzed the crawler logs last week and saw that a lot of merged-*-min.css.gz are collected there. During a test, I then saw that the minify files are created with every page view.

First load - 07.07.2024 - 11:47:57: /typo3temp/assets/compressed/merged-1e691d4e2026e04f3027483bb0cd5cf8-min.css.gz?1720345677

Second load - 07.07.2024 - 11:48:38: /typo3temp/assets/compressed/merged-1e691d4e2026e04f3027483bb0cd5cf8-min.css.gz?1720345718

In this commit, the check if the file has already been created was removed: https://github.com/a-r-m-i-n/min/commit/7fd99535d964beac893d2c28ba149e0a21ca3baa#diff-0121e1183a0acdd190c5bbfdb63e3a197f72ee7e89c4c6407cd2a27589c0877dL129

Subject version: 3.0.1 (12 LTS) and 2.1.3 (11 LTS/10 LTS)

Solution idea: https://github.com/a-r-m-i-n/min/blob/4966c4cd8e6aa7edab9b77902cdb3d9cc9c937b7/Classes/Minifier.php#L99

            // File already created for this ext
            if (file_exists($targetFilename)) {
                $config['file'] = $targetFilename;
                $filesAfterCompression[$targetFilename] = $config;
                continue;
            }

Bye Björn

a-r-m-i-n commented 2 months ago

I've discovered, that the generation is only generating, if the new request is uncached (e.g. using CTRL+F5).

However, this should of course not happen all the time.

a-r-m-i-n commented 2 months ago

I've also discovered, that this behaviour only occurs, when you are logged in to the TYPO3 backend.

So, I would leave it as it is.