Joomla Performance: Specify a Cache Validator

More
07 Nov 2017 02:25 - 21 Aug 2026 23:56 #4889 by Trony


If You test your Website with a tools like GTmetrix , You could find a suggestion like Specify a cache validator:

The following resources are missing a cache validator. Resources that do not specify a cache validator cannot be refreshed efficiently. Specify a Last-Modified or ETag header to enable cache validation for the following resources


First Step


Check in your htaccess if You have these rules:
Code:
FileETag None Header unset ETag Header unset Last-Modified

I suggest to comment with # and put FileETag MTime Size:
Code:
FileETag MTime Size #FileETag None #Header unset ETag #Header unset Last-Modified

Second Step


Sometimes Joomla did not ETag header and so, You Edit index.php of Your Template and You put at top this PHP's Code:
Code:
<?php $etagFuso= md5_file($_SERVER['SCRIPT_FILENAME']); header('ETag: '. 'W/"'.$etagFuso.'"', true ); ?>
I prefer to use Weak ETag Validation instead Strong.
You can read more here: Strong and Weak validation

Conclusions


You can to use only Last Modified Header but ETag is more Compatible with some Browsers and Bots (Bing for Example).

Do You ❤️ It?!? Buy Me a Coffee! Thank You in advance... ✌️


Support me on Ko-fi

"Music and Electronic Devices Designer. Drum and Bass Addict. Creative Mind as Lifestyle. Cat in past Life. Football, Ice Hockey and Snowboard Lover. Marxist."


Sono Il Re sul Carro Danzante.
Attraversando La Città Getto Via I Coriandoli Della Vostra Tristezza Regalando Passione Ed Estasi Nei Vostri Occhi.

😼 This-Ads-Feeds-My-Cats