ProcessWire-AIOM-All-In-One-Minify
ProcessWire-AIOM-All-In-One-Minify copied to clipboard
Incorrect re-use of CSS-file
The function _getCacheName uses the last_modified timestamp to generate a unique filename.
In my case, I use the same LESS files for 2 different page templates, except for 1 LESS file (which depends on the page template used). So I should get a different CSS file in this template. But unfortunately the 2 LESS files that differ have exactly the same last_modified timestamp, so the same filename is generated for the CSS file. This results in incorrect classes in the CSS file included in 1 of the pages.
Sehr geehrte Damen und Herren,
vielen Dank für Ihre Nachricht. Ich bin vom 16. bis einschließlich 29. Juni 2014 nicht im Haus und werde mich umgehend nach meiner Wiederkehr um die Beantwortung Ihrer E-Mail kümmern.
Beste Grüße, David Karich
FlipZoom Media Inc. David Karich Sieglarer Straße 65 - 67 53842 Troisdorf
Tel.: +49(0) 22 41 · 90 53 40-4 Mobil: +49(0) 1 71 · 7 40 85 51 E-Mail: [email protected] Web: www.flipzoom.de
Inhaber: David Karich St.-Nr.: 220 / 5211 / 1444 USt-IdNr.: DE285718045 Amtsgericht: Siegburg
Why use modtime? I often FTP a few files to the server in less than a second and they all become identical when cached because the modtime is the same. I'm trying this out instead:
private static function _getCacheName($files, $prefix = 'css_', $ext = '.css') {
$_pathtext = '';
foreach ($files as $file) {
$_pathtext .= $file['absolute_path'];
}
return (self::$developmentMode !== true) ? $prefix.md5($_pathtext).$ext : $prefix.md5($_pathtext).'_dev'.$ext;
}
Other than that, this module has been a joy to use. Thanks. (SteveB on PW forum)
Hello sb3b and MarkMagStream,
we're looking for a different solution to handle in the next major version. I personally like the idea of sb3d to use a md5.
Thanks for reporting!
Thanks to forum member SteveB pointing me to this, which I totally missed when I searched for the problem!
I had a similar issue, and came up with a solution like sb3d; but I used the modified timestamp as well as the path. If the timestamp isn't present, I'd be concerned that the same cache file name would be generated all the time, even when they change. When changes are made to the source files, the generated file will have the same name, and so could still be cached by browsers.
I also had an issue with duplicate md5 hashes as I could not rely on the modified timestamp. After deployment of my website via FTP all css files had the same timestamp. I used also both the absolute path and the modified timestamp which made it work for me.
Why is this simple fix still not included? I can't see any reason to not fix this issue now, even if you are already planning the next major release.