get to know http caching - liquidpixels.com · http caching web traffic, the flow of information...

8
Get to Know HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every page, image, font, stylesheet, javascript — everything needed by your browser to display a page — arrives when your browser makes an HTTP request and receives an HTTP response. Since everything that makes up a page must be retrieved from a web server, opportunities to streamline the process can have huge benefits. HTTP caching is an important mechanism that can significantly enhance the web experience. But, like most things in technology, HTTP caching also comes with its own tradeoffs. Get Started u

Upload: others

Post on 22-Sep-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every

Get to Know HTTP CachingWeb traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every page, image, font, stylesheet, javascript — everything needed by your browser to display a page — arrives when your browser makes an HTTP request and receives an HTTP response.

Since everything that makes up a page must be retrieved from a web server, opportunities to streamline the process can have huge benefits. HTTP caching is an important mechanism that can significantly enhance the web experience. But, like most things in technology, HTTP caching also comes with its own tradeoffs.

Get Started u

Page 2: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every

2n 866.808.4937 n liquidpixels.com n

What Is Caching Exactly?

It might be helpful to think of caching similarly to how you manage your contacts in your cell phone. (Stick with us on this, we promise it will make sense.)

Nancy wants the number for a local pizza place, so she performs a Google search to find it.

Preparing for the next time she wants to order a pizza —as fast as Google is, searching every time is inconvenient — Nancy would need to memorize the number or, more likely enter it into her cell phone contacts, or write it in her address book (for less immediate, old-school access). And, just to hedge all bets, Nancy also receives a printed phone book from her phone company every year.

This seems ideal: commonly used numbers are in Nancy’s contact list, in the phonebook, or, as a last resort, available with some Google sleuthing.

Now let’s say Nancy’s favorite pizza place enjoys huge success, moves to a larger storefront in a new building, and gets a new phone number. Nancy could consult her memory, her cell phone directory, her address book, or her copy of the phonebook, yet she would still only have the old, outdated number. In an effort to save time, she would have traded-off the accuracy of the phone number data. The data she has would be out-of-date, the carefully constructed information systems would break down, and Nancy would be hungry.

Page 3: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every

3n 866.808.4937 n liquidpixels.com n

http://www.liquidpixels.com/

This is Great… But What Does It Mean For My Business?

In order to understand what this all means for your business, you should first get yourself a slice of your favorite pizza, because after all that food talk, I’m sure you’re hungry. However, silence your hunger pangs and we’ll continue.

The above example describes a multi-level cache system. While simplified and pizza-ized, it accurately represents the HTTP caching system relied upon by any e-commerce company using the web today.

As a website publisher (or, an up-and-coming pizza place owner), your website’s information is delivered from your web server to your client (Nancy) the first time your client requests a page from your site. After that initial request, a copy of each HTTP request’s response data is stored in one or more caches for faster subsequent recall. HTTP caching benefits both clients and servers. Clients, like Nancy, benefit from faster load times, and servers benefit from reduced request rates.

Additionally, every browser in use today contains an internal cache which follows these behaviors. So, even without any additional infrastructure, caching still unavoidably takes place. It’s common for e-commerce companies to employ a Content Delivery Network (CDN), additional caching at the web server, or both. A typical three-level cache infrastructure, including a CDN and browser cache, looks like this:

Your Server

External Cache (CDN)

Browser Cache

Page 4: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every

4n 866.808.4937 n liquidpixels.com n

Managing Cache Flow

As is true of so many things, all of the benefits of caching come with an important tradeoff. It is not possible to have both a perfect cache of data while maintaining the freshest version of your website. Some of the objects stored in one of the caches may be older versions of objects that would otherwise be served directly from the server.

To manage this tradeoff, HTTP requires that objects served from a web server carry information describing how they may be cached, including at minimum, the date at which they expire. Any cache containing a copy of an object older than its expiration date must disregard that object and instead make a fresh request upstream. Each individual object — HTML content, images, Javascript — can carry different expiry times as appropriate for that object. HTTP provides many ways for both the web server and web browser (client) to influence the caches between them.

Suppose your website is serving objects with a one-week expiry time. A client visits your website, causing the CDN cache and their browser cache to both store the current copy of all objects required to display a product page.

The next day, you update your website, updating product descriptions, pricing, and product photography. Customers visiting your website may not see these changes — the expiry date has not been reached, the CDN’s cache has objects from the previous day, and therefore your customer will see the cached, old copy.

There is a balance between the speed of your website and the accuracy of its content. In a perfect world, you would have both. However, the delicate balance between speed and accuracy is one that you must decide for your business based on criteria you set forth.

Page 5: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every

5n 866.808.4937 n liquidpixels.com n

Keeping Cache In Hand

One arguably imprudent way to combat the speed -vs- accuracy problem is to direct your chosen CDN to flush the cache manually every single time you update your site. While some companies take that approach, it is not the perfect solution. Flushing the CDN cache manually increases the resource demands of deployment, which is where mistakes can be made due to manual intervention. And it leaves any objects cached at the browser or other caches you can’t control untouched and stale.

Focused on the reduction of requests directed to your web servers — offload or cache-hit-ratio — CDNs may store objects for a fixed CDN-determined timeframe, disregarding the HTTP directives from your web server. An extended cache period may help deliver website information more quickly, but only addresses half the situation. Longer expiration periods means more offload, but also means more potentially stale content, and requires more cumbersome manual flushing.

Extended cache expirations also leave your company more exposed. With later expiration dates, your customers are more likely to receive outdated information. This is especially worrisome if you employ dynamic software that’s designed to shift and transform your content according to your customers’ needs. Long expiry times can prevent rendering on a request-by-request basis,. Your customers could be loading images of old products in retired colors … and you won’t even know.

Page 6: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every

6n 866.808.4937 n liquidpixels.com n

You Have My Attention. Now What Do I Do?

Proper cache management isn’t easy. But here are some things you can do to make cache systems work for you:

Stay Flexible

One answer to today’s “speed vs. accuracy” question is to take advantage of flexible cache management. If you choose to partner with LiquidPixels, you’ll reap all of the benefits of dynamic imaging and dynamic cache flow. Our media services collaborators enable us to embed per-request expiration dates into the images we serve. Translation? You can manage your content to render and cache differently, specific to each request. You will never have to flush your entire cache system again.

Know Your CDN

Do your research. Partner with a CDN that has your best interests at heart, understands HTTP caching and the tradeoffs, and meets your unique specifications.

Understand and Leverage Standards

HTTP cache management may seem complex, but it’s an always present part of the web today. At LiquidPixels, for example, our products always adhere to cache control directives. When you employ LiquiFire® OS, you activate CDN services that always obey your wishes. If you ask our solutions to observe an expiration date, they listen.

Page 7: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every

7n 866.808.4937 n liquidpixels.com n

Poor cache management could be harming your business. Start reorganizing your cache infrastructure by chatting with an expert in cache control.

Want to learn more about cache management and its broader implications for business? Curious about the delicate balance between speed and accuracy? Contact the LiquidPixels team. We’d love to be of help.

Contact a LiquidPixels team member through our website, on Twitter, or at 866-808-4937.

About Us

LiquidPixels leads the imaging revolution. Built on open standards, our LiquiFire Dynamic Imaging Solutions integrate into existing Web and workflow environments, enhancing product creation and visualization, while reducing production costs. LiquidPixels makes its patented technology available as a hosted service or via on-site enterprise servers with solutions that may be tailored to each of our customers’ unique needs. If you’d like to find out more about us, we’d love to tell you.

Contact us at LiquidPixels.com.

© 2017 LiquidPixels Inc. All rights reserved.

Page 8: Get to Know HTTP Caching - liquidpixels.com · HTTP Caching Web traffic, the flow of information from a web server to your browser, is transferred using a protocol called HTTP. Every