Tricky Caching reverse Proxy - different User agents to be watched
Ryan Malayter
malayter at gmail.com
Mon May 10 17:10:25 MSD 2010
On Mon, May 10, 2010 at 2:41 AM, musa <nginx-forum at nginx.us> wrote:
> Well, in this case (realy small page, short caching time) it doesnt matter when it caches for each user-agent.
The user-agent string contains a lot more than just the browser
version, unfortunately. It can also includes the versions of various
browser plug-ins, add-ons, etc., which means you are caching a
different version of each page for IE8 users with one version of .NET
or another.
For example, here's a full user-agent string pulled from our logs:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0;
SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729;
Media Center PC 6.0; InfoPath.2)
To eliminate unnecessary requests to the back-end as well as
duplicated cache entries, it might be best to use the nginx map module
to "normalize" the User-Agent to just a few values:
http://wiki.nginx.org/NginxHttpMapModule
For example (syntax not tested, just a guess based on documentation):
map $http_user_agent $shortua {
default anybrowser;
*iPhone* iPhone;
*Blackberry* bb;
*IEMobile* winmoble;
"*Windows Phone*" winmobile;
}
proxy_cache_key "$scheme$proxy_host$uri$is_args$args $shortua";
--
RPM
More information about the nginx
mailing list