{"id":563,"date":"2013-04-15T17:36:47","date_gmt":"2013-04-16T00:36:47","guid":{"rendered":"http:\/\/pln.lanecc.net\/webteam\/?p=563"},"modified":"2013-04-15T17:36:47","modified_gmt":"2013-04-16T00:36:47","slug":"caching-changes","status":"publish","type":"post","link":"https:\/\/blogs.lanecc.edu\/webteam\/2013\/04\/15\/caching-changes\/","title":{"rendered":"Caching Changes"},"content":{"rendered":"<p>Once <a title=\"Speeding up Drupal 7\" href=\"http:\/\/pln.lanecc.net\/webteam\/2012\/06\/15\/speeding-up-drupal-7\/\">again<\/a>, we&#8217;re on a quest to make the website as fast as possible. Drupal doesn&#8217;t make this easy &#8211; on an average page load, our request for that page passes through three servers, sometimes generating hundreds of database calls and touching dozens of files. But through\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Web_cache\">caching<\/a>, we&#8217;re able to skip most of those steps and serve you content that was already waiting for you.<\/p>\n<p>Now that we&#8217;re a couple of weeks post launch, we&#8217;re going to start making our caching a little more aggressive. If you&#8217;re a web editor, this might impact you.<\/p>\n<p>Previously, the cache time on all of the objects (pictures, fonts, stylesheets, etc) on our pages was set to six hours. This makes sense the first few days after a big launch &#8211; we were anticipating lots of changes. But now that things have stabilized some, we&#8217;re turning up the cache lifetime on our stylesheets and javascript files to one year, and turning the cache lifetime of images up to one month. For 99% of visitors to the Lane website, this will result in up to 17 fewer requests to our servers &#8211; a 70% savings &#8211; creating a significantly faster web experience.<\/p>\n<p>Unfortunately, this also means that there&#8217;s certain circumstances when a picture you&#8217;ve added to your website remains in the cache, and you&#8217;re unable to force someone to use a new one. Let&#8217;s say that you have a picture, called &#8220;kitten.jpg&#8221;, of a kitten eating a hamburger. You save your page, and people flock to see your awesome image. Every one of their browsers sees that the picture has an expires header of 111600 seconds &#8211; 31 days. Next time they visit your page, their browser won&#8217;t attempt to download that picture again unless at least 111600 seconds has passed.<\/p>\n<p>The bad situation happens when you want to replace your kitten picture with a better one (say, a picture of your kitten eating a cheeseburger). You upload your new file as &#8220;kitten.jpg&#8221;. But your visitors will never see the new picture &#8211; their browsers see the same filename, and they know that particular file hasn&#8217;t expired from their cache yet.<\/p>\n<p>So how do you fix it? Well, for one, remember that the picture will automatically fix after 31 days. But if you need an immediate fix, there&#8217;s a simple trick. Just rename your picture as &#8220;kitten2.jpg&#8221; and add it to your page like a new image. Now when the browser visits the page it&#8217;ll realize that it doesn&#8217;t need kitten.jpg anymore, and grab kitten2.jpg instead. We&#8217;re setting the cache at 1 year for JavaScript and stylesheets because we&#8217;re able to depend on Drupal to create new stylesheet and JavaScript names automatically when they change, and effectively do the same thing as we did with kitten.jpg in the example.<\/p>\n<p>Things are actually a bit more involved than what&#8217;s above, but it&#8217;s not worth the extra confusion. If you&#8217;re interested in how we&#8217;re actually implementing caching, please send me an email or leave a comment.<\/p>\n<p>I know this extra renaming step might seem painful, but we can&#8217;t ignore page speed. Google is <a href=\"http:\/\/www.mattcutts.com\/blog\/site-speed\/\">incorporating speed into their rankings<\/a>, and for users on slow connections (3g, in particular), we want to make sure the page renders in less than 1 second. Caching will take us a long way towards where we want to be.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once again, we&#8217;re on a quest to make the website as fast as possible. Drupal doesn&#8217;t make this easy &#8211; on an average page load, our request for that page passes through three servers, sometimes generating hundreds of database calls and touching dozens of files. But through\u00a0caching, we&#8217;re able to skip most of those steps &hellip; <a href=\"https:\/\/blogs.lanecc.edu\/webteam\/2013\/04\/15\/caching-changes\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Caching Changes&#8221;<\/span><\/a><\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":"","_wpscppro_dont_share_socialmedia":false,"_wpscppro_custom_social_share_image":0,"_facebook_share_type":"","_twitter_share_type":"","_linkedin_share_type":"","_pinterest_share_type":"","_linkedin_share_type_page":"","_instagram_share_type":"","_medium_share_type":"","_threads_share_type":"","_google_business_share_type":"","_selected_social_profile":[],"_wpsp_enable_custom_social_template":false,"_wpsp_social_scheduling":{"enabled":false,"datetime":null,"platforms":[],"status":"template_only","dateOption":"today","timeOption":"now","customDays":"","customHours":"","customDate":"","customTime":"","schedulingType":"absolute"},"_wpsp_active_default_template":true},"categories":[3,5],"tags":[11],"class_list":["post-563","post","type-post","status-publish","format-standard","hentry","category-drupal","category-technical","tag-geek"],"_links":{"self":[{"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/posts\/563","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/comments?post=563"}],"version-history":[{"count":0,"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/posts\/563\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/media?parent=563"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/categories?post=563"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.lanecc.edu\/webteam\/wp-json\/wp\/v2\/tags?post=563"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}