Specify a cache validator
-
Hi
When i enable AI i get ?Specify a cache validator? for all the jpg’s that the plugin generates. When i disable the plugin i do not get this recommendation (tested on: google pageSpeed, gtmetrix).
Is there a way to fix this in the code that the plugin injects into .htaccess? For your information: i have w3 Total cache installed.
Thanks a lot for your interest.
regards
theo
-
It is quite possible that, when Google scans your website, the plugin does not recognise this and serves the Google bot the full sized images.
However, I am not sure if we would want to change this. On the one hand this would remove the recommendation, but, on the other hand Google would not be able to download and index the actual images.
The intention (so far) is to target the mobile devices exclusively. So the only true way to test if the plugin works is in real mobile environment or an emulated mobile environment (webpagetest.org supports this and I recommend it).
Hi Nevma
I tested again with google chrome pageSpeed and gtmetrix.
I also tried webpagetest.org but couldn’t find the specify cache validator recommendation.
The result for the first two mentioned environments are both the same.
The scaled images are clearly recocnised. But somehow AI disables the cache validator not only for the scaled, but for all other images that are not scaled too.
You might say that the speed gained balances this lack. But the visual impact of a missing cache validator is less good. The rendering of the images is delayed, they lag.I made a test adding an .htaccess file to cache/adaptive-images
<filesMatch "\.(jpg|png)$"> Header set Expires "Thu, 21 May 2016 20:00:00 GMT" Header set Last-Modified "Thu, 21 May 2015 20:00:00 GMT" </filesMatch>
But i had no effect.
I guess there is no easy fix for this issue.
Thanks for your interest.
regards
theoHi Nevma
With the plugin turned off, the cache validators are ok.
With the plugin turned on, the recommendation: specify a cache validators is displayed in several testing environments.
Since the plugin apparently takes over control of specifying the cache validator, how about giving this control back to .htaccess?
If that is possible, where would that be?
In ai-main.php perhaps?What do you think?
regards
theoOh, no, I wouldn’t say that the speed gained balances the lack of caching! That would not be fair… It seems that the plugin does not sent the caching headers for images correctly. But it should! I’m going to check it out and see what is wrong there…
We have a “Browser cache” settings that is supposed to set the browser cache headers. I will check if it is not working properly!
I am a little baffled.
The plugin sets the cache headers correctly. For instance:
Date: Tue, 26 May 2015 14:29:35 GMT Server: Apache Cache-Control: private, max-age=15552000 Expires: Sun, 22 Nov 2015 14:29:35 GMT Content-Length: 266596 x-frame-options: SAMEORIGIN Content-Type: image/jpeg 200 OK
Where do the pageSpeed and gtmetrix refer to when they say they couldn’t find the specify cache validator recommendation?
Hi Nevma
Sorry, i didn’t mean to offend you, when i said that the speed gained balances the lack of unspecified cache validators. I apologize.
Here are two measurments for https://www.creatifpassion.ch with gtmetrix and google pageSpeed.
————————————————————————
first gtmetrix
Test Server Region: Vancouver, Canada
Using: Chrome (Android, Galaxy Nexus) 26.0.1410.58, Page Speed 1.12.16, YSlow 3.1.8Result for 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:` fonts.googleapis.com/css?family=Butterfly+Kids&subset=latin%2Clatin-ext&ver=4.2.2
url/wp-content/themes/mystile-creatifpassion/images/bx_loader.gif
url/wp-content/themes/mystile-creatifpassion/images/bxslider_sprite.png
url/wp-content/uploads/2014/12/Pampers_kuchen_slider.jpg
url/wp-content/uploads/2014/12/Sandra_2013_010-229×229.jpg
url/wp-content/uploads/2014/12/Sandra_2013_039-229×229.jpg
url/wp-content/uploads/2014/12/Sandra_2013_041_slide.jpg
url/wp-content/uploads/2014/12/Sandra_2013_042_slide.jpg
url/wp-content/uploads/2014/12/Sandra_2013_044_slide.jpg
url/wp-content/uploads/2014/12/Sandra_2013_045_slide.jpg`second google chrome pageSpeed
using: Mozilla/5.0 (Linux; Android 4.4.2; GT-I9505 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Mobile Safari/537.36
Result for cache validator:
Cache-Validierer angebenDurch die Angabe eines Cache-Validierers (Last-Modified- oder ETag-Header) stellen Sie sicher, dass die Gültigkeit der im Cache gespeicherten Ressourcen effizient ermittelt werden kann.
Weitere InformationenVorschl?ge für diese Seite:
Für die folgenden Ressourcen fehlt ein Cache-Validierer. Ressourcen, für die kein Cache-Validierer angegeben ist, k?nnen nicht effizient aktualisiert werden. Geben Sie einen Last-Modified- oder ETag-Header an, um die Cache-Validierung für folgende Ressourcen zu aktivieren:
https://fonts.googleapis.com/css?…
url/…/bx_loader.gif
url/…/bxslider_sprite.png
url/…/Pampers_kuchen_slider.jpg
url/…/Sandra_2013_010-229×229.jpg
url/…/Sandra_2013_039-229×229.jpg
url/…/Sandra_2013_041_slide.jpg
url/…/Sandra_2013_042_slide.jpg
url/…/Sandra_2013_044_slide.jpg
url/…/Sandra_2013_045_slide.jpg
url/…/android-chrome-192×192.png
url/…/favicon-16×16.png
url/…/favicon-32×32.png
url/…/favicon-96×96.pngcompared to webpagetest:
(just one image)HTTP/1.1 200 OK Date: Tue, 26 May 2015 16:40:42 GMT Connection: Keep-Alive Keep-Alive: timeout=5, max=100 X-Powered-By: PHP/5.5.24 Cache-Control: public, max-age=31536000 Expires: Wed, 25 May 2016 16:40:42 GMT Content-Type: image/jpeg Cache-Control: private, max-age=15552000 Expires: Sun, 22 Nov 2015 16:40:42 GMT Content-Length: 5892 Vary: User-Agent Connection: keep-alive Vary: User-Agent
Conclusion: gtmetrix/google PageSpeed and webpagetest measure differently. Now, what is right?
regards
theoHello, again,
I tested a demo installation of my own where I have the plugin installed and the gtmetrix results are here https://gtmetrix.com/reports/clients.nevma.gr/qzrxGwkd. It seems that it gets 97/100 at the “Specify a cache validator” metric!
Can you tell me if it reports any images in the resources that are missing a cache validator?
Oh, I just read your message above! No offense taken! Actually, I meant that you are right! ?? Written speech can be misleading some times.
And now I read your whole message above.
Well, it seems that I do not get the same message when I run the gtmetrix tool! That is weird. However, it seems that the Last-modified header is missing and this is something I can add. And I will! ??
I added the Last-modified header and it seems to work!
Would like to check it for me? You could add this line of code
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', filemtime( $filename ) ) . ' GMT' );
right after line 96 of the file /adaptive-images/adaptive-images/ai-main.php.
Then I can commit it to a new version!
Hi Nevma
Ok, i’ll test it.
Will report soon.
Thanks
theoHi Nevma
I run the test after making the changes you suggest.
No luck, for the images are no longer scaled.
I also tried to clear the cache and checked again on gtmetrix and google PageSpeed.
The plugin seems to be out of service.
You can try on gtmetrix with the domain i tested:test this site on gtmetrix
Thanks
theoConfirm, no scaling happens
theoHi Nevma
This morning i tested another site with a fullwidth image slider.
I added the code you provided in ai-main.php and this removes
the recommendation specify a cache validator.
Everything works as expected for this site.
For the other site, i guess it is the configuration of w3 Total cache, that causes problems. I’ll take a look at that.Thanks a lot for your help and the code.
regards
theop.s.: i found the cause, it was autoptimize plugin that somehow disabled AI from working properly. I apologize for the trouble.
- The topic ‘Specify a cache validator’ is closed to new replies.