Http headers can instruct what kind of cache mechanism browser and proxy should obey along the request/response chain. For static resources (Javascript, CSS, images, flash etc), it is suggested to apply cache on browser or proxy side to reduce # of Http requests.
Response Headers:
Cache-Control Tells all caching mechanisms from server to client whether they may cache this object (public/private to control if browser or proxy cache, no-store to control if save to disk, max-age is to control how long to cache)
Expires Gives the date/time after which the response is considered stale (suggested 1 year from now, for aggressive static resource cache)
Date The date and time that the message was sent (It is useful for Expires by date time)
ETag An identifier for a specific version of a resource, often a message digest (Suggest to disable it for performance, or re-configure ETag to remove server specific info. See If-None-Match. ETag takes precedence over Last-Modified if both exist)
Last-Modified The last modified date for the requested object, in RFC 2822 format (for conditional get, 304 Not Modified, see If-Modified-Since)
Pragma Implementation-specific headers that may have various effects anywhere along the request-response chain. (Http1.0, example is Pragma: no-cache)
Vary Tells downstream proxies how to match future request headers to decide whether the cached response can be used rather than requesting a fresh one from the origin server. (The most common case is to set Vary: Accept-Encoding, so that proxy knows if return cached compressed data to browser)
Request Headers:
Cache-Control Used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain
If-Modified-Since Allows a 304 Not Modified to be returned if content is unchanged
If-None-Match Allows a 304 Not Modified to be returned if content is unchanged
Pragma Implementation-specific headers that may have various effects anywhere along the request-response chain
Recommendations:
It is important to specify one of Expires or Cache-Control max-age, and one of Last-Modified or ETag, for all cacheable resources. It is redundant to specify both Expires and Cache-Control: max-age, or to specify both Last-Modified and ETag.
You use the Cache-control: public header to indicate that a resource can be cached by public web proxies in addition to the browser that issued the request.
Avoiding caching
HTTP version 1.1 -> Cache-Control: no-cache
HTTP version 1.0 -> Setting the Expires header field value to a time earlier than the response time
Reference
http://tools.ietf.org/html/rfc2616
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching
http://code.google.com/p/doctype/wiki/ArticleHttpCaching
Thursday, August 4, 2011
Tuesday, August 2, 2011
Mobile Web Optimization Webinar Takeaway
Last week I attended a webinar from Compuware talking about mobile web optimization using page speed. The talk was very clear and well organized. It first went through the importance of mobile web performance, then discussed key difference between mobile and desktop, then detailed page speed rules about mobile web.
Browser is the entry point to mobile web
The browser is becoming the integration platform
The browser is becoming more complex
- # of hosts per user transaction
- Many RIA frameworks
- Performance differences across devices
Free performance tools
Page Speed
WebPagetest
dynaTrace Ajax Edition
Mobile web page load process
Mobile channel establishment
DNS lookup
TCP connect
Http request
Parse & Layout (subrequests)
Key differences between mobile and desktop
Networks:
round-trip time (High channel establishment time, lower RTT)
bandwidth (3G vs Cable)
Devices:
CPU (JS execution times, layout times, 10x JS runtime cost, 1 ms per kb parsing)
memory (more code/objects - more GC, more DOM, more memory)
Interaction model
(touch vs click, mobile click event with 300-500ms delay)
Page Speed Rules
Use an application cache (how about localstorage?)
Defer JS parsing (how about deferring JS download?)
make landing page redirects cacheable (Cache-control: private, max-age > 0) (How long? 301 and 302 are both cacheable?)
prefer touch events (why not disable click event on mobile?)
Reference:
http://slidesha.re/qgC8n3
http://www.slideshare.net/Gomez_Inc/optimizing-web-and-mobile-site-performance-using-page-speed
Browser is the entry point to mobile web
The browser is becoming the integration platform
The browser is becoming more complex
- # of hosts per user transaction
- Many RIA frameworks
- Performance differences across devices
Free performance tools
Page Speed
WebPagetest
dynaTrace Ajax Edition
Mobile web page load process
Mobile channel establishment
DNS lookup
TCP connect
Http request
Parse & Layout (subrequests)
Key differences between mobile and desktop
Networks:
round-trip time (High channel establishment time, lower RTT)
bandwidth (3G vs Cable)
Devices:
CPU (JS execution times, layout times, 10x JS runtime cost, 1 ms per kb parsing)
memory (more code/objects - more GC, more DOM, more memory)
Interaction model
(touch vs click, mobile click event with 300-500ms delay)
Page Speed Rules
Use an application cache (how about localstorage?)
Defer JS parsing (how about deferring JS download?)
make landing page redirects cacheable (Cache-control: private, max-age > 0) (How long? 301 and 302 are both cacheable?)
prefer touch events (why not disable click event on mobile?)
Reference:
http://slidesha.re/qgC8n3
http://www.slideshare.net/Gomez_Inc/optimizing-web-and-mobile-site-performance-using-page-speed
90% line in JMeter aggregate report
I considered 90% line is the response data 90% users will see, but recently realized this was wrong. JMeter online Help has detailed explanation about every item in Aggregate report.
The 90% line tells you that 90% of the samples fell at or below that number. However, it is more meaningful than average in terms of SLA. We expect it within 2x of average time. That is, if average time is 500ms, we expect 90% line is less than 1000ms. Otherwise the system fluctuates a lot.
The 90% line tells you that 90% of the samples fell at or below that number. However, it is more meaningful than average in terms of SLA. We expect it within 2x of average time. That is, if average time is 500ms, we expect 90% line is less than 1000ms. Otherwise the system fluctuates a lot.
Subscribe to:
Posts (Atom)