{"id":8550,"date":"2017-11-15T04:00:52","date_gmt":"2017-11-15T08:00:52","guid":{"rendered":"https:\/\/blog.litespeedtech.com\/?p=8550"},"modified":"2017-11-15T04:00:52","modified_gmt":"2017-11-15T08:00:52","slug":"wpw-optimizing-images-with-lscache","status":"publish","type":"post","link":"https:\/\/lswp.store\/index.php\/2017\/11\/15\/wpw-optimizing-images-with-lscache\/","title":{"rendered":"WpW: Optimizing Images with LSCache"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" title=\"\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-4.png\" alt=\"\" width=\"640\" height=\"320\" \/><\/p>\n<p>Welcome to another installment of <a href=\"http:\/\/blog.litespeedtech.com\/tag\/wordpress-wednesday\">WordPress Wednesday<\/a>!<\/p>\n<p><em><strong>Disclaimer<\/strong>: The information contained in this post is accurate for LSCWP v1.6.2.1 [<a href=\"https:\/\/wordpress.org\/plugins\/litespeed-cache\/#developers\">release log<\/a>]. If you are using a newer version of the plugin, some details may have changed. Please<a href=\"https:\/\/www.litespeedtech.com\/support\/wiki\/doku.php\/litespeed_wiki:cache:lscwp\"> refer to our wiki<\/a> for the latest!<\/em><\/p>\n<p>Have you ever wished that your site\u2019s images didn\u2019t take so long to transfer? Well, there may be something you can do about it. Many images can be optimized to take up less space, which in turn takes less time to transfer. Two and a half weeks ago, we introduced an Image Optimization feature, and in that time, we\u2019ve already optimized around 640,000\u00a0images. That\u2019s a lot of saved bytes!<\/p>\n<p>Intrigued? <strong>Today we\u2019re going to talk a little bit about Image Optimization<\/strong>: what it is, and how to use it.<\/p>\n<h2>Image Optimization<\/h2>\n<p>One effective way to deal with the cost of transmitting images over the Internet is to reduce the size of those images.<\/p>\n<p><strong>Smaller images = faster transmissions.<\/strong><\/p>\n<p>The LiteSpeed Cache plugin provides access to image optimization services on a central web server. Here\u2019s how it works:<\/p>\n<ol>\n<li>You press the <strong>Send Optimization Request<\/strong> button on the <strong>Image Optimization<\/strong> page.<\/li>\n<li>The central server denies or accepts the request after callback verification.<\/li>\n<li>The central server distributes the task to a child server.<\/li>\n<li>The child server fetches your images.<\/li>\n<li>The child server processes your images.<\/li>\n<li>The child server notifies WordPress that the images are ready.<\/li>\n<li>A cron job runs and pulls your images back into WordPress.<\/li>\n<\/ol>\n<p><img decoding=\"async\" title=\"\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-1.jpeg\" alt=\"\" width=\"672\" height=\"448\" \/><\/p>\n<p>You may be wondering about step 5. What is actually happening when the child server processes your images?<\/p>\n<p>Well, there are libraries for this sort of thing, so we don&#8217;t need to reinvent the wheel. We use <a href=\"http:\/\/php.net\/manual\/en\/class.imagick.php\">Imagick<\/a> functions to adjust your images to 85%-90% quality of the original. (This optimization is lossy.)<\/p>\n<p>During the process, three versions of each image file are generated:<\/p>\n<ul>\n<li><code>yourimage.bk.jpg<\/code>: the original version of your image.<\/li>\n<li><code>yourimage.jpg<\/code>: the optimized version of your image, which is what will be shown on your site from now on.<\/li>\n<li><code>yourimage.jpg.webp<\/code>: is a version of your image saved in a format that is about 25%-34% smaller than JPG (<a href=\"https:\/\/developers.google.com\/speed\/webp\/\">learn more<\/a>).<\/li>\n<\/ul>\n<p>If <code>yourimage.jpg<\/code> was unable to be optimized for any reason (maybe it was already optimal) there will be no new version generated, and therefore no <code>yourimage.bk.jpg<\/code>. There <em>will<\/em> be a WebP format saved, though.<\/p>\n<h3>Using multiple plugins<\/h3>\n<p>Before we go any further, it\u2019s important to point out that <strong>you should not use more than one Image Optimization plugin at the same time<\/strong>! Doing so can cause quirky behavior, and it often leads to errors in processing: errors that can only be cleared by creating a ticket and having us deal with it on our end.<\/p>\n<p>It\u2019s extra hassle for everyone involved, so please just don\u2019t do it &#x1f642;<\/p>\n<p>Generally speaking, it\u2019s never a good idea to have two plugins performing the same optimization functions anyway. To be clear, you can still use multiple optimization plugins, as long as you don\u2019t duplicate any of the individual functions. <a href=\"https:\/\/lswp.store\/2017\/08\/02\/wpw-using-multiple-cache-plugins\/\">I go into more detail on that here<\/a>, if you want to know more.<\/p>\n<h2>How do I use Image Optimization on my WordPress Site?<\/h2>\n<h3>Settings<\/h3>\n<p>From the WordPress Dashboard, navigate to <strong>LiteSpeed Cache &gt; Settings &gt; Media<\/strong>. Scroll down, and you will see two settings related to optimization.<\/p>\n<p><img decoding=\"async\" title=\"\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-5.png\" alt=\"\" width=\"672\" height=\"313\" \/><\/p>\n<p><strong>Disable Optimization Pull<\/strong>, when &#8216;ON&#8217;, will disable the cron job that is used to pull optimized images from the central server into your WordPress media library. If you turn this on, you will be unable to retrieve your optimized images.<\/p>\n<p>Under normal circumstances, you will not need to touch this setting.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-6.png\" alt=\"\" width=\"672\" height=\"313\" \/><\/p>\n<p>Remember the <code>.webp<\/code> file format we mentioned earlier? If you would like to use WebP images in place of all of your JPGs and PNGs, turn the <strong>Image WebP Replacement<\/strong> option on.<\/p>\n<p>Not all browsers support WebP, so there will be two versions of your pages in cache: one with the WebP images and one with the other image formats, and the appropriate version will be served to your visitors. And since your other optimized image formats are still there, you can turn WebP off at any time, if you change your mind.<\/p>\n<h3>Optimize<\/h3>\n<p>Navigate to <strong>LiteSpeed Cache &gt; Image Optimization<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-7.png\" alt=\"\" width=\"672\" height=\"230\" \/><\/p>\n<p>The first time you visit this page, you will see a button that reads <strong>Request Key<\/strong>. Press the button to obtain a key from the central server that it will use to process all of your future image optimization requests. Once the key is obtained, your screen should look like the one shown below, and your API key will be listed (although most of it will be blocked out for security purposes).<\/p>\n<p>Below the key is <strong>Total Reduction<\/strong>. It shows you how much space the server has saved with image optimization to date. This number isn&#8217;t updated automatically, so to get the most recent status you will need to press the <strong>Update Reduction Status<\/strong> button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-8.png\" alt=\"\" width=\"672\" height=\"477\" \/><\/p>\n<p>Below <strong>Optimization Summary<\/strong>, you\u2019ll see <strong>Image Information<\/strong>.<\/p>\n<p>The top section of <strong>Image Information<\/strong> is where you submit your request.<\/p>\n<ul>\n<li><strong>Images Total<\/strong> displays the number of images present on your site.<\/li>\n<li><strong>Images Not Yet Requested<\/strong> shows the number of images yet to be optimized.<\/li>\n<li>Press <strong>Send Optimization Request<\/strong> and all of the unoptimized will be submitted to the central server for optimization.<\/li>\n<\/ul>\n<p>The bottom area of this section shows you what&#8217;s happening with your current request.<\/p>\n<ul>\n<li><strong>Images requested<\/strong>: how many images are waiting their turn to be optimized<\/li>\n<li><strong>Images optimized and waiting to be pulled<\/strong>: how many are complete and waiting to be pulled back into WordPress<\/li>\n<li><strong>Images optimized and pulled<\/strong>: how many have finished the process completely<\/li>\n<\/ul>\n<p>All of this happens behind the scenes after you&#8217;ve pressed the <strong>Send Optimization Request<\/strong> button. You can refresh the page to update these numbers, and you can leave the page while optimization is running, if you&#8217;ve got other things to do.<\/p>\n<h3>Restore<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" title=\"\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-9.png\" alt=\"\" width=\"672\" height=\"425\" \/><\/p>\n<p>If you are unhappy with the way an image was optimized, you have the ability to restore it back to the original version. From the WordPress Dashboard, navigate to <strong>Media &gt; Library<\/strong>, choose the list view, and hover over the image you\u2019d like to revert.<\/p>\n<p>Click <code>Restore Original File<\/code> and everything goes back to normal.<\/p>\n<p>If you have enabled WebP images globally, you can disable it for individual images using the <code>Disable WebP<\/code> link.<\/p>\n<h2>Comparing Pages With and Without Optimization<\/h2>\n<p><a href=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-8566\" src=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-10-404x1024.png\" alt=\"\" width=\"197\" height=\"500\" srcset=\"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-10-404x1024.png 404w, https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-10-118x300.png 118w, https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-10-607x1536.png 607w, https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-10-600x1519.png 600w, https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-10.png 667w\" sizes=\"(max-width: 197px) 100vw, 197px\" \/><\/a><\/p>\n<p>I created a few image-heavy blog posts, using differently-sized images for each.<\/p>\n<p>With no optimization whatsoever, my post with the largest images in it had to transfer 14,070,859 bytes of imagery. After optimization, it was 9,467,154 bytes. Nice! And when I enabled WebPs, it was even better at 7,249,465 bytes! <strong>Image optimization cut the image size nearly in half.<\/strong><\/p>\n<p>Your mileage will vary based on how optimized your images already are when they\u2019re uploaded. If you\u2019re a photographer, and you take pains to export your images from Lightroom or Photoshop already nicely-optimized, you will see much less of an improvement (if any) than someone who doesn\u2019t pay too much attention to their imagery before upload.<\/p>\n<p>I saw this in action on a post where the imagery transfer took 353,370 bytes before and <em>after<\/em> optimization. My images were clearly already optimized. However, when I enabled WebP, it went down to 250,520 bytes. So at the very least, you should be able to see <em>some<\/em> improvement by enabling WebP.<\/p>\n<p><strong>Image Optimization<\/strong> has been a popular topic on our WordPress forum lately, and there have been a lot of questions about what, exactly, it is doing to your photos. I hope that this has lifted some of the mystery. And if you still have questions, please do ask!<\/p>\n<p>&#8212;<br \/>\nHave some of your own ideas for future <a href=\"http:\/\/blog.litespeedtech.com\/tag\/wordpress-wednesday\">WordPress Wednesday<\/a> topics? Leave us a comment!<\/p>\n<p>Don\u2019t forget to meet us back here next week for the next installment. In the meantime, here are a few other things you can do:<\/p>\n<ul>\n<li>Subscribe to the <a href=\"http:\/\/blog.litespeedtech.com\/tag\/wordpress-wednesday\/feed\/\">WordPress Wednesday RSS feed<\/a><\/li>\n<li>Download <a href=\"https:\/\/wordpress.org\/plugins\/litespeed-cache\/\">LiteSpeed Cache for WordPress plugin<\/a><\/li>\n<li>Learn more about the plugin <a href=\"https:\/\/www.litespeedtech.com\/products\/cache-plugins\/wordpress-acceleration\">on our website<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wished that your site\u2019s images didn\u2019t take so long to transfer? Well, here is something you can do about it!<\/p>\n","protected":false},"author":1,"featured_media":8552,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[28],"tags":[144,316,317],"class_list":["post-8550","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cache","tag-image-optimization","tag-wordpress","tag-wordpress-wednesday"],"jetpack_featured_media_url":"https:\/\/lswp.store\/wp-content\/uploads\/2017\/11\/null-4.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/posts\/8550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/comments?post=8550"}],"version-history":[{"count":0,"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/posts\/8550\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/media\/8552"}],"wp:attachment":[{"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/media?parent=8550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/categories?post=8550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lswp.store\/index.php\/wp-json\/wp\/v2\/tags?post=8550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}