Title: Cache Validator / Last Modified Header
Last modified: November 22, 2018

---

# Cache Validator / Last Modified Header

 *  Resolved [mlepisto](https://wordpress.org/support/users/mlepisto/)
 * (@mlepisto)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/)
 * Hi,
 * So I have the plugin working now and it seems to be doing well. However, one 
   thing I noticed that is when the rewrites are enabled and I do a speed test with
   say Gtmetrics, all the images (jpg & png) that are being converted give a “specify
   cache validator” warning/error. When I remove the rules from the .htaccess file
   the plugin creates, these warnings/errors go away so I’m fairly certain it has
   to do with the plugin.
 * This is probably more a feature request than anything else, but I was wondering
   if you have any suggestions on how to handle this before I start hacking at things.
 * Thanks,
    Mika

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [rosell.dk](https://wordpress.org/support/users/roselldk/)
 * (@roselldk)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-10916235)
 * Hi Mika,
 * Yes, it appears that performance can be improved if WebP Express adds a Last-
   Modified header to the image responses. It will be quite easily implemented. 
   I will implement it in the WebP Convert library. I have created an issue for 
   it here: [https://github.com/rosell-dk/webp-convert/issues/86](https://github.com/rosell-dk/webp-convert/issues/86)
 *  Plugin Author [rosell.dk](https://wordpress.org/support/users/roselldk/)
 * (@roselldk)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-10972398)
 * Done.
 * A Last-Modified header has been implemented in 0.8.0, which has just been released
 *  Thread Starter [mlepisto](https://wordpress.org/support/users/mlepisto/)
 * (@mlepisto)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-10977682)
 * Thanks [@roselldk](https://wordpress.org/support/users/roselldk/) !
 *  [mr_spock](https://wordpress.org/support/users/mr_spock/)
 * (@mr_spock)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11290081)
 * Hi, I must be dumb – where is this set?
 *  Plugin Author [rosell.dk](https://wordpress.org/support/users/roselldk/)
 * (@roselldk)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11290114)
 * It is set by the converter (when an image is redirected to the converter).
 * When an image is redirected directly to an existing webp through the Apache rewrite
   rule, it will also be set automatically by Apache. Same goes for Nginx
 *  [mr_spock](https://wordpress.org/support/users/mr_spock/)
 * (@mr_spock)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11290226)
 * Sorry, but that’s not happening. Check it out at [https://www.abiquo.com](https://www.abiquo.com)–
   the htaccess rules (which I just forced the plugin to rewrite) are below. I’ve
   tried changing the expires header, that works fine. Any other ideas?
 *     ```
       # BEGIN WebP Express
       <IfModule mod_rewrite.c>
         RewriteEngine On
   
         # Redirect to existing converted image in cache-dir (if browser supports webp)
         RewriteCond %{HTTP_ACCEPT} image/webp
         RewriteCond %{REQUEST_FILENAME} -f
         RewriteCond %{DOCUMENT_ROOT}/wp-content/webp-express/webp-images/doc-root/wp-content/$1.$2.webp -f
         RewriteRule ^/?(.+)\.(jpe?g|png)$ /wp-content/webp-express/webp-images/doc-root/wp-content/$1.$2.webp [NC,T=image/webp,E=EXISTING:1,L]
   
         # Set Cache-Control header so these direct redirections also get the header set
         # (and also webp-realizer.php)
         <IfModule mod_headers.c>
           <FilesMatch "\.webp$">
             Header set Cache-Control "public, max-age=31536000"
           </FilesMatch>
         </IfModule>
   
         # Fall back to mod_expires if mod_headers is unavailable
         <IfModule !mod_headers.c>
           <IfModule mod_expires.c>
             ExpiresActive On
             ExpiresByType image/webp "access plus 1 years"
           </IfModule>
         </IfModule>
   
         # WebP Realizer: Redirect non-existing webp images to webp-realizer.php, which will locate corresponding jpg/png, convert it, and deliver the webp (if possible) 
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteRule ^/?(.+)\.(webp)$ /wp-content/plugins/webp-express/wod/webp-realizer.php?xdestination-rel=xwp-content/$1.$2&wp-content=wp-content [NC,L]
   
         # Redirect images to webp-on-demand.php (if browser supports webp)
         RewriteCond %{HTTP_ACCEPT} image/webp
         RewriteCond %{REQUEST_FILENAME} -f
         RewriteCond %{QUERY_STRING} (.*)
         RewriteRule ^/?(.+)\.(jpe?g|png)$ /wp-content/plugins/webp-express/wod/webp-on-demand.php?xsource-rel=xwp-content/$1.$2&wp-content=wp-content&%1 [NC,L]
   
         <IfModule mod_headers.c>
           <IfModule mod_setenvif.c>
             # Set Vary:Accept header for the image types handled by WebP Express.
             # The purpose is to make proxies and CDNs aware that the response varies with the Accept header. 
             SetEnvIf Request_URI "\.(jpe?g|png)" ADDVARY
             Header append "Vary" "Accept" env=ADDVARY
   
             # Set X-WebP-Express header for diagnose purposes
             # Apache appends "REDIRECT_" in front of the environment variables defined in mod_rewrite, but LiteSpeed does not.
             # So, the next line is for Apache, in order to set environment variables without "REDIRECT_"
             SetEnvIf REDIRECT_EXISTING 1 EXISTING=1
             Header set "X-WebP-Express" "Redirected directly to existing webp" env=EXISTING
           </IfModule>
         </IfModule>
   
       </IfModule>
       <IfModule mod_mime.c>
         AddType image/webp .webp
       </IfModule>
       ```
   
 *  Plugin Author [rosell.dk](https://wordpress.org/support/users/roselldk/)
 * (@roselldk)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11290323)
 * Just curious. Are you on version 0.12?
 * I can see that requesting [https://www.abiquo.com/wp-content/uploads/2018/02/abiquo_logo_224x94-2.jpg](https://www.abiquo.com/wp-content/uploads/2018/02/abiquo_logo_224x94-2.jpg)
   gives me the following headers (among others):
 * cache-control: public, max-age=31536000
    content-type: image/webp date: Fri, 
   08 Mar 2019 12:47:58 GMT expires: Sat, 07 Mar 2020 12:47:58 GMT pragma: public
   server: Apache/2.4.37 (Amazon) x-webp-express: Redirected directly to existing
   webp
 * The x-webp-express header tells me that it was an internal redirect.
    And you
   are right, there are no Last-Modified header.
 * I’m thinking that it does not matter in your case, because the Last-Modified 
   header is as far as I know only useful when other headers, such as cache-control
   or expires are missing.
 * But I’m curious. Does the server send the Last-Modified header when you unset
   Cache-Control? (it could be that the server does not care to set the Last-Modified
   header because it is superfluous)
 *  [mr_spock](https://wordpress.org/support/users/mr_spock/)
 * (@mr_spock)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11290930)
 * I don’t really care about it except some of the speed testing tools think it’s
   important so I’m concerned about search rank.
 * I’ll try the cache-control later…
 *  Plugin Author [rosell.dk](https://wordpress.org/support/users/roselldk/)
 * (@roselldk)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11291131)
 * Here is someone advocating (and showing how) to turn Last-Modified OFF for images:
 * [https://www.askapache.com/htaccess/apache-speed-last-modified/](https://www.askapache.com/htaccess/apache-speed-last-modified/)
 * It is commented on here:
    [https://webmasters.stackexchange.com/questions/27694/last-modified-etags-to-include-or-not](https://webmasters.stackexchange.com/questions/27694/last-modified-etags-to-include-or-not)
 * And here is more on the subject:
    [https://serverfault.com/questions/292070/how-to-setup-apache-2-2-3-to-send-last-modified-etc](https://serverfault.com/questions/292070/how-to-setup-apache-2-2-3-to-send-last-modified-etc)
 *  [mr_spock](https://wordpress.org/support/users/mr_spock/)
 * (@mr_spock)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11691586)
 * I eventually tested removing the cache control setting, and there’s still no 
   last-modified.
 *  Plugin Author [rosell.dk](https://wordpress.org/support/users/roselldk/)
 * (@roselldk)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11790845)
 * [@mr_spock](https://wordpress.org/support/users/mr_spock/): Ok. This is not how
   it behaves on the Apache servers that I have access to (I get the Last-Modified
   header). I see from the “server” response header that you are on Amazon (it is“
   Apache/2.4.37 (Amazon)”). It could perhaps be that they for some reason decided
   policy.
 * But wait, I just had a more careful look at the .htaccess rules that you posted.
   Here is an extract:
 *     ```
       # Set Cache-Control header so these direct redirections also get the header set
         # (and also webp-realizer.php)
         <IfModule mod_headers.c>
           <FilesMatch "\.webp$">
             Header set Cache-Control "public, max-age=31536000"
           </FilesMatch>
         </IfModule>
   
         # Fall back to mod_expires if mod_headers is unavailable
         <IfModule !mod_headers.c>
           <IfModule mod_expires.c>
             ExpiresActive On
             ExpiresByType image/webp "access plus 1 years"
           </IfModule>
         </IfModule>
       ```
   
 * Removing the first block will is not enough as the second block is only going
   to have effect on systems where the mod_headers are unavailable.
    The above should
   be replaced with this:
 *     ```
           <IfModule mod_expires.c>
             ExpiresActive On
             ExpiresByType image/webp "access plus 1 years"
           </IfModule>
       ```
   
 * Or rather: You should place this outside the WebP Express section in the FAQ,
   in order for it not to be overridden later.
 * Does that work?

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Cache Validator / Last Modified Header’ is closed to new replies.

 * ![](https://ps.w.org/webp-express/assets/icon.svg?rev=1918288)
 * [WebP Express](https://wordpress.org/plugins/webp-express/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/webp-express/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/webp-express/)
 * [Active Topics](https://wordpress.org/support/plugin/webp-express/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/webp-express/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/webp-express/reviews/)

 * 11 replies
 * 3 participants
 * Last reply from: [rosell.dk](https://wordpress.org/support/users/roselldk/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/cache-validator-last-modified-header/#post-11790845)
 * Status: resolved