• Resolved Ian Pegg

    (@ianpegg)


    Firstly, thank you Frank for all your hard work on this plugin. I’m not trying to curry your favour by saying it’s better than paid alternatives I’ve used, that is simply the truth!

    I’ve set the plugin up to cache YT thumbnails locally for better performance. For browser cache expiration I have a default setting of 31557600 seconds (about a year) for images. In spite of this, the thumbnails generated by your plugin have an expiration of 1 week, even though they have a content type of image/jpeg.

    Here are the browser cache settings I’m using (as provided by LiteSpeed):

    <IfModule mod_expires.c>
    ExpiresActive on
    
    ExpiresByType image/jpg A31557600
    ExpiresByType image/jpeg A31557600
    ExpiresByType image/png A31557600
    ExpiresByType image/gif A31557600
    ExpiresByType image/webp A31557600
    
    </IfModule>

    The images are served through CloudFlare, but I’ve set that to respect existing headers sent by the origin. All other images on the site have the above expiration times.

    Is your plugin setting its own cache expiration on the thumbnails it generates? If so, is there any way to override this behaviour – or – is there a good reason not to?

    Thanks for your help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    Hey Ian;
    The expiry-time is explicitly set to 1w indeed in lyteCache.php, you could change it there?

    Reasons for this 1w is that some users change thumbnails in YouTube and the changes was never reflected + a German user got a copyright infringement claim due to a thumbnail being used with an image that he did not have rights to and to lessen the strength of such claims the “cache lifetime” both in browser and in the LYTE thumbnail cache had to be somewhat limited.

    hope this clarifies,
    frank

    Thread Starter Ian Pegg

    (@ianpegg)

    Thanks, @optimizingmatters, that does indeed clarify.

    I could easily change the $expireTime variable in the script, but that might be overwritten next time I update the plugin.

    Would you be able to add a filter or else turn that variable into a constant that can be set in wp-config?

    Cheers!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I’ll look into that Ian.

    Thread Starter Ian Pegg

    (@ianpegg)

    Thanks Frank. If I get time over the next few days I’ll try my hand at it myself and submit a PR with my suggested implementation.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    OK, https://github.com/futtta/wp-youtube-lyte/commit/3d6352065bb6ca717133a7c9895c376fcf800708 should do it, it will honor the LYTE_CACHE_EXPIRE_TIME constant being set (can be in wp-config.php or elsewhere) instead of the hardcoded value, would be great if you could test? ??

    Thread Starter Ian Pegg

    (@ianpegg)

    Sure thing, Frank. I’m now testing it out, will let you know how it goes…

    Thread Starter Ian Pegg

    (@ianpegg)

    I realised that the lyteCache.php script is called directly outside of the WP environment, therefore setting a constant in wp-config.php will not work.

    However, I noticed that this script is already looking for a script called lyteCache-config.php in the web root directory, so I created this file on my test server and added the constant into there. That worked a treat, albeit there was a small typo in the new else statement you added into lyteCache.php: $expireTIme should of course be $expireTime ??

    So, now the cached thumbnails have whatever expiry time I want, which is fantastic!

    However, I think I’ve spotted a regression with your previous commit. The test plugin is now only able to fetch the generic grey “video was deleted” thumbnail. I checked the API key on my test server and it is definitely working okay – the last official release is still able to fetch the correct thumbs in this environment too.

    I have a hunch the issue is owing to the change you made to get_origThumbURL() – could be worth checking that extra logic that you added to the conditional. I’ve left a comment in the commit on github for reference.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Control over browser cache expiration’ is closed to new replies.