Quantcast
Channel: LowEndTalk
Viewing all articles
Browse latest Browse all 39981

nginx question

$
0
0

hello, i need nginx help

i am experimenting nginx caching, and this works:

fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:5m max_size=1000m;

server {
    listen 80;
    server_name domain.com www.domain.com;
    access_log /var/log/nginx/website.access_log;
    error_log /var/log/nginx/website.error_log;
    root /home/jon/temp/php/domain.com;
    index index.php index.htm index.html;
    location ~ .php$ {
        try_files $uri $uri/ /index.php;
        set $no_cache "";
        if ($request_method !~ ^(GET|HEAD)$) {
            set $no_cache "1";
        }
        if ($no_cache = "1") {
            add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
            add_header X-Microcachable "0";
        }
        if ($http_cookie ~* "_mcnc") {
                    set $no_cache "1";
        }
        fastcgi_no_cache $no_cache;
        fastcgi_cache_bypass $no_cache;
        fastcgi_cache microcache;
        fastcgi_cache_key $server_name|$request_uri;
        fastcgi_cache_valid 404 30m;
        fastcgi_cache_valid 200 10s;
        fastcgi_max_temp_file_size 1M;
        fastcgi_cache_use_stale updating;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass_header Set-Cookie;
        fastcgi_pass_header Cookie;
        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param  PATH_INFO          $fastcgi_path_info;
        fastcgi_param  PATH_TRANSLATED    $document_root$fastcgi_path_info;
        include fastcgi_params;

my question is, can i use the microcache for multiple domains? e.g. define fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=microcache:5m max_size=1000m; in nginx.conf and use microcache for all domain in server? or is cache one for each domain i will host?

sorry, i am not very well versed with nginx. thanks!


Viewing all articles
Browse latest Browse all 39981

Trending Articles