{
    "version" : "https://jsonfeed.org/version/1",
    "content" : "guides",
    "type" : "single",
    "title" : "Conserve resources, recycle when possible |Digital.gov",
    "description": "Conserve resources, recycle when possible",
    "home_page_url" : "/preview/gsa/digitalgov.gov/bc-archive-content-3/","feed_url" : "/preview/gsa/digitalgov.gov/bc-archive-content-3/guides/mobile-principles/cache/index.json","item" : [
    {"title" :"Conserve resources, recycle when possible","summary" : "Week five of our series offers tips for increasing page loading speeds, and making the mobile web experience better for users overall.","date" : "2018-12-10T10:00:00-05:00","date_modified" : "2025-01-27T19:42:55-05:00","primary_image" : { "uid" : "guide-mobile-principles", "alt" :
  "Vector illustration of a mobile phone", "width" :
  "1200", "height" :
  "630", "credit" :
  "Irina_Strelnikova/iStock via Getty Images", "caption" :
  "", "format" :
  "png" },"branch" : "bc-archive-content-3",
      "filename" :"principles-cache.md",
      
      "filepath" :"guides/mobile-principles/principles-cache.md",
      "filepathURL" :"https://github.com/GSA/digitalgov.gov/blob/bc-archive-content-3/content/guides/mobile-principles/principles-cache.md",
      "editpathURL" :"https://github.com/GSA/digitalgov.gov/edit/bc-archive-content-3/content/guides/mobile-principles/principles-cache.md","slug" : "cache","url" : "/preview/gsa/digitalgov.gov/bc-archive-content-3/guides/mobile-principles/cache/","aliases" : {"0" : "/resources/mobile/principles/cache"},"content" :"\u003cp\u003eEven as successive generations of mobile devices put more speed and power at our fingertips, mobile network speeds continue to lag behind. \u003ca href=\"http://www.speedtest.net/global-index/united-states\"\u003eAs of October 2018\u003c/a\u003e, the average mobile download speed in the U.S. was just over one quarter of fixed broadband speeds. These limitations show how mobile connectivity still presents unique challenges for web developers who aim to deliver the best user experience possible. This week’s principle offers tips for increasing page loading speeds, and making the mobile web experience better for users overall.\u003c/p\u003e\n\u003cp\u003eTwo solutions that may improve the loading of your site include:\u003c/p\u003e\n\u003col\u003e\n\u003cli\u003eLeverage browser caching\u003c/li\u003e\n\u003cli\u003eAvoid landing page redirects\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eBoth of these solutions may improve the performance and usability of your site and can be detected using Google\u0026rsquo;s \u003ca href=\"https://search.google.com/test/mobile-friendly\"\u003eMobile Friendly Test\u003c/a\u003e tool, \u003ca href=\"https://www.digitaldashboard.gov\"\u003eDigitalDashboard.gov\u003c/a\u003e, or the \u003ca href=\"https://itif.org/publications/2017/03/08/benchmarking-us-government-websites\"\u003eInformation Technology \u0026amp; Innovation Foundation (ITIP) Benchmarking Report\u003c/a\u003e.\u003c/p\u003e\n\u003ch2 id=\"leverage-browser-caching\"\u003eLeverage Browser Caching\u003c/h2\u003e\n\u003cp\u003e\u003cstrong\u003eIssue: Use browser caching to reduce traffic to and from the server fetching resources\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eFetching resources over the Internet can be slow, especially if it requires multiple round trips between the client and server. This “extra work” delays processing and blocks rendering of page content. All server responses should specify a caching policy to allow the client to determine if, and when, it can reuse a previously-fetched response. This will prevent extra trips downloading the same component multiple times. It may take longer to \u003ca href=\"https://varvy.com/pagespeed/first-view.html\"\u003erender a page on first view\u003c/a\u003e, as it is fetching all of the resources—but on return visits, \u003ca href=\"https://varvy.com/performance/application-cache.html\"\u003ethe cache\u003c/a\u003e will help the site render faster.\u003c/p\u003e\n\u003cp\u003e\u003cstrong\u003eSolution: Develop and optimize your caching strategy and include server caching headers\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eThis is a two-pronged solution: first develop a caching strategy that meets your needs, and then implement the strategy using caching headers.\u003c/p\u003e\n\u003ch3 id=\"develop-and-optimize-your-caching-strategy\"\u003eDevelop and Optimize Your Caching Strategy\u003c/h3\u003e\n\u003cp\u003eOrganizations must create an optimal caching strategy or policy. This involves examining each resource and answering questions, such as:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eCan the resource can be cached, and by whom?\u003c/li\u003e\n\u003cli\u003eHow long should the cache be retained?\u003c/li\u003e\n\u003cli\u003eHow can the files be revalidated when the caching policy expires?\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eDifferent page resources can have different expiration dates, with more frequently updated resources set to expire sooner.  For example, static content (such as global CSS styles and logos) may last a year, while JavaScript, .html, and .pdf files may change more frequently and only last a month—or even a day—depending on your site.\u003c/p\u003e\n\u003cp\u003eBy extending the caching time as long as possible, round-trip fetching can be reduced, which will reduce server processing time and increase the browser rendering speed. A word of caution: setting the caching parameters too long may cause users to keep older file versions after updates and to not have the latest data.\u003c/p\u003e\n\u003ch3 id=\"include-server-caching-headers\"\u003eInclude Server-Caching Headers\u003c/h3\u003e\n\u003cp\u003eTo enable browser caching you need to edit your HTTP headers to set expiring times for certain types of files. This may be done differently depending on your server, or if you are using a Content Management System (CMS), cache extensions, or newly-available server side plugins.\u003c/p\u003e\n\u003cp\u003eMost enable caching by adding “caching parameters” to the \u003ccode\u003e.htaccess\u003c/code\u003e file. These parameters tell the cache how long to keep the file.\u003c/p\u003e\n\u003cp\u003eAn \u003ca href=\"https://deluxeblogtips.com/htaccess-rules-website-performace/\"\u003eexample of the “caching parameters”\u003c/a\u003e of an \u003ccode\u003e.htaccess\u003c/code\u003e file is:\u003c/p\u003e\n\u003cpre\u003e[...]\n\u0026lt;IfModule mod_expires.c\u0026gt;\nExpiresActive On\nExpiresByType text/html \"access plus 1 hour\"\nExpiresByType image/gif \"access plus 1 day\"\nExpiresByType image/jpeg \"access plus 1 day\"\nExpiresByType image/png \"access plus 1 years\"\nExpiresByType text/css \"access plus 2 months\"\nExpiresByType text/javascript \"access plus 1 years\"\nExpiresByType application/x-javascript \"access plus 1 years\"\nExpiresByType application/javascript \"access plus 1 years\"\n\u0026lt;/IfModule\u0026gt;\n[...]\u003c/pre\u003e\n\u003ch3 id=\"references\"\u003eReferences:\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003eLeverage Browser Caching \u003ca href=\"https://developers.google.com/speed/docs/insights/LeverageBrowserCaching\"\u003ehttps://developers.google.com/speed/docs/insights/LeverageBrowserCaching\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eLeverage Browser Caching \u003ca href=\"https://varvy.com/pagespeed/leverage-browser-caching.html\"\u003ehttps://varvy.com/pagespeed/leverage-browser-caching.html\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003ePageSpeed: Leverage Browser Caching \u003ca href=\"https://gtmetrix.com/leverage-browser-caching.html\"\u003ehttps://gtmetrix.com/leverage-browser-caching.html\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e3 Simple .htaccess Rules For Better Website Performance \u003ca href=\"https://deluxeblogtips.com/htaccess-rules-website-performace/\"\u003ehttps://deluxeblogtips.com/htaccess-rules-website-performace/\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"avoid-landing-page-redirects\"\u003eAvoid Landing Page Redirects\u003c/h2\u003e\n\u003cp\u003e\u003cstrong\u003eIssue: Redirects trigger an additional HTTP request-response cycle and delay page rendering, wasting time.\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eRedirects trigger an additional HTTP request-response cycle (round trip to the server) and delay page rendering. Each redirect adds an HTTP request-response, and may perform additional Domain Name System (DNS) lookups, Transmission Control Protocol (TCP) handshakes, and Transport Layer Security (TLS) negotiation. This increases the time it takes to render the site on the mobile device.\u003c/p\u003e\n\u003cp\u003eHowever, redirects may be inevitable:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003ewhen a resource has moved,\u003c/li\u003e\n\u003cli\u003efor tracking and logging of referring pages,\u003c/li\u003e\n\u003cli\u003eto allow for \u0026ldquo;user-friendly\u0026rdquo; or \u0026ldquo;vanity\u0026rdquo; domains and URLs, and catch misspelled or mistyped URLs, or\u003c/li\u003e\n\u003cli\u003eto connect between different parts of a site, country code top-level domains, different protocols, different security policies, etc.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u003cstrong\u003eSolution: Minimize use of redirects to improve site performance\u003c/strong\u003e\u003c/p\u003e\n\u003cp\u003eYou want to minimize the number of redirects issued by your application, especially for resources essential to rendering the page. Only use redirects when absolutely technically necessary, and find other solutions where it is not. If your site requires redirects, Google has provided some more \u003ca href=\"https://developers.google.com/search/mobile-sites/mobile-seo/separate-urls#automatic-redirection\"\u003edetailed guidelines for Automatic Redirection\u003c/a\u003e.\u003c/p\u003e\n\u003ch3 id=\"references-1\"\u003eReferences:\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003eAvoid Landing Page Redirects \u003ca href=\"https://developers.google.com/speed/docs/insights/AvoidRedirects\"\u003ehttps://developers.google.com/speed/docs/insights/AvoidRedirects\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003ePageSpeed Avoid Landing Page Redirects \u003ca href=\"https://gtmetrix.com/avoid-landing-page-redirects.html\"\u003ehttps://gtmetrix.com/avoid-landing-page-redirects.html\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eHow to Avoid Landing Page Redirects \u003ca href=\"https://rigor.com/blog/2016/09/how-to-avoid-landing-page-redirects\"\u003ehttps://rigor.com/blog/2016/09/how-to-avoid-landing-page-redirects\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003eAutomatic Redirection \u003ca href=\"https://developers.google.com/search/mobile-sites/mobile-seo/separate-urls#automatic-redirection\"\u003ehttps://developers.google.com/search/mobile-sites/mobile-seo/separate-urls#automatic-redirection\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n"}
  ]
}
