Welcome! Log In Create A New Profile

Advanced

RE: proxy_cache ramdisk

February 02, 2010 12:58PM
-----Original Message-----
From: Ryan Malayter [mailto:malayter@gmail.com]
Sent: Tuesday, February 02, 2010 8:43 AM
To: nginx@nginx.org
Subject: Re: proxy_cache ramdisk

On Mon, Feb 1, 2010 at 11:35 AM, Igor Sysoev <igor@sysoev.ru> wrote:
>> All pages on this site have a login option so I guess caching our site
isn't
>> a good idea.
>
> Yes, even if you cache them properly in nginx, they will have poor hit
ratio.
> However, you may try to cache non-personalized pages.

You can cache pages for "public" users that aren't logged in, and then
serve the pages directly without caching to users who are logged in.
This can be done simply by simply changing the URI in your application
a bit.

For example, anonymous users would hit "http://example.com/index.php",
and the application could return a "Cache-Control:
public,max-age=3600". After a user logs in, you can simply redirect
them to "http://example.com/loggedin/index.php". This virtual diectory
can run the same code, but instead it sets a "Cache-Control: private,
max-age=0" header. So logged in users would not received cached pages.

Another option in nginx would be to use $http_cookie (or a variable
based on it) as part of the proxy_cache_key. Users with an empty
cookie would get the cached page for public users, while users that
have logged in and have a session cookie would be proxied directly to
the back-end. Again, you should set appropriate "Cache-Control"
headers in the application for anonymous versus logged-in users.

Finally, all of your static images, .js files, and CSS files should
have appropriate cache-control headers, so they can be cached for both
logged-in and anonymous users. As Igor points out, this only makes
sense if those files are not already "local" to the nginx server, but
are instead being served from back-end via proxy. You should set
Cache-Control headers on these files even if you aren't using nginx
proxy_cache at all, since you still want to take advantage of any
caches "downstream" from you (such as at the user's ISP, or in their
corporate datacenter). These shared caches are actually more common
than people think, and many are transparent to end-users. When we
first implemented cache-control headers on static files many years
ago, our bandwidth bill dropped by 75% in one month.

--
RPM

_______________________________________________


Good to know... thanks!


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

proxy_cache ramdisk

testbot January 29, 2010 11:48AM

RE: proxy_cache ramdisk

testbot January 30, 2010 01:50PM

RE: proxy_cache ramdisk

testbot January 31, 2010 05:30PM

Re: proxy_cache ramdisk

Igor Sysoev February 01, 2010 11:40AM

RE: proxy_cache ramdisk

testbot February 01, 2010 11:54AM

Re: proxy_cache ramdisk

Igor Sysoev February 01, 2010 12:10PM

RE: proxy_cache ramdisk

testbot February 01, 2010 12:30PM

Re: proxy_cache ramdisk

Igor Sysoev February 01, 2010 12:40PM

Re: proxy_cache ramdisk

Ryan Malayter February 02, 2010 09:48AM

RE: proxy_cache ramdisk

testbot February 02, 2010 12:58PM

Re: proxy_cache ramdisk

Ryan Malayter January 31, 2010 10:08PM

Re: proxy_cache ramdisk

nexthop January 31, 2010 10:14PM

Re: proxy_cache ramdisk

Ryan Malayter February 01, 2010 09:20AM

RE: proxy_cache ramdisk

testbot February 01, 2010 11:04AM

Re: proxy_cache ramdisk

Ryan Malayter February 01, 2010 05:50PM

RE: proxy_cache ramdisk

testbot February 01, 2010 11:10AM

RE: proxy_cache ramdisk

danny February 01, 2010 11:22AM

Re: proxy_cache ramdisk

Akins, Brian February 01, 2010 08:04AM

Re: proxy_cache ramdisk

Igor Sysoev February 01, 2010 11:42AM

Re: proxy_cache ramdisk

nexthop February 01, 2010 12:24PM

Re: proxy_cache ramdisk

Igor Sysoev February 01, 2010 12:36PM

Re: proxy_cache ramdisk

nexthop February 01, 2010 08:58PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 243
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready