• Resolved jab2870

    (@jab2870)


    Hi,

    I am testing this plugin on a local version of my site so can’t share a URL.

    I have built a plugin that looks to see if the HTTP_ACCEPT header includes ‘image/webp’ and if it does, it serveres a webp version of the image.

    Unfortunately, the cached version of the files do not perform this check and, as a result, browsers that do not support webp images are being sent cached pages that include <img src="my/image.webp" />

    • This topic was modified 6 years ago by jab2870.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Sa?a

    (@stodorovic)

    You should create WPSC plugin which can create separate cache file (wp-cache instead of super-cache file in this case) based on request headers. Also, you should set “Simple” instead of “Expert” delivery method.

    Regarding to WPSC plugin, you need to add cache action (filter) wp_cache_key which should be unique ‘key’ for cache file. Something like this:

    add_cacheaction( 'wp_cache_key', 'my_webp_key' );
    
    function my_webp_key( $key ) {
    	if ( isset($_SERVER['HTTP_ACCEPT']) && $_SERVER['HTTP_ACCEPT'] === 'blablabla' ) {
    		$key .= 'blablabla';
    		$super_cache_enabled = false; // Use wp-cache file.
    	}
    
    	return $key;
    }
    

    It can’t be added in plugins or theme because it should be executed early before loading plugins. You can read more on https://odd.blog/2017/10/25/writing-wp-super-cache-plugins/.

    Thread Starter jab2870

    (@jab2870)

    Thanks for the quick reply! That has sorted it.

    jab2870 – does that mean you’ve written a plugin that will display the webp version of an image on supported browsers and work with WP Supercache Plugin? That is something I am looking for. Please let me know if it is publicly available.

    Thread Starter jab2870

    (@jab2870)

    Hi Starvoters1,

    I am working on such a plugin. It is not publically available yet although I hope it will be soon.

    I am currently in the testing phases before I publish it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Web P images’ is closed to new replies.