flash service

High_Performance_Web_Sites

Issue link: https://read.uberflip.com/i/1146286

Contents of this Issue

Navigation

Page 98 of 169

How Redirects Hurt Performance | 77 The 301 and 302 status codes are the ones used most often. Status codes 303 and 307 were added in the HTTP/1.1 specification to clarify the (mis)use of 302, but the adoption of 303 and 307 is almost nonexistent, as most web sites continue to use 302. Here's an example of the headers in a 301 response. HTTP/1.1 301 Moved Permanently Location: http://stevesouders.com/newuri Content-Type: text/html The browser automatically takes the user to the URL specified in the Location field. All the information necessary for a redirect is in the headers. The body of the response is typically empty. Despite their names, neither a 301 nor a 302 response is cached in practice unless additional headers, such as Expires or Cache-Control, indi- cate that it should be. There are other ways to automatically redirect users to a different URL. The meta refresh tag included in the head of an HTML document redirects the user after the number of seconds specified in the content attribute: JavaScript is also used to perform redirects by setting the document.location to the desired URL. If you must do a redirect, the preferred technique is to use the stan- dard 3xx HTTP status codes, primarily to ensure the Back button works correctly. For more information about this, see the W3C web article "Use standard redirects: don't break the back button!" at http://www.w3.org/QA/Tips/reback. How Redirects Hurt Performance Figure 11-1 shows how redirects slow down the user experience. The first HTTP request is the redirect. Nothing is displayed to the user until the redirect is com- pleted and the HTML document is downloaded. Figure 11-1. Redirects slow down web pages redirect html script stylesheet stylesheet stylesheet image image

Articles in this issue

Links on this page

Archives of this issue

view archives of flash service - High_Performance_Web_Sites