[Tiki-devel] Caching with Nginx

Fabio Montefuscolo <[email protected]>
Newsgroups gmane.comp.cms.tiki.devel
Message-ID <CAF4KPBQo1MZr8gwYm69k==mu+Q2Kqq=Eftp5omi=iK=W1pm=GQ@mail.gmail.com>
Hello people!

As I said before, Nginx is a great tool for caching. Just for fun, I tried
to cache everything from dev.tiki.org, but proxying from my server. I have
a domain, dev.tiki.blue proxying and caching dev.tiki.org. The first
request to a page might be slow, the second is faster.

Important things if someone wants to check

* it is an experiment!
* there are no rules to bypass the cache for GET methods ... so please DO
NOT LOGIN there, otherwise, your private pages will be cached.
* there is no cache to POST and PUT methods, so the search is not cached

Not sure if attachments work here, so I am pasting the Nginx config below
...

------
proxy_cache_path /var/cache/devto-cache levels=1:2 keys_zone=DEVTO:50m
 max_size=10g inactive=1y use_temp_path=off;

server {
        listen 80;
        server_name dev.tiki.blue;
        access_log /var/log/virtualmin/dev.tiki.blue_access_log;
        error_log /var/log/virtualmin/dev.tiki.blue_error_log;

        root /home/tiki/domains/dev.tiki.blue/public_html;
        index index.html index.htm index.php;

        location / {
                return 301 https://$server_name$request_uri;
        }
}

server {
        listen 443 ssl;
        server_name dev.tiki.blue;

        root /home/tiki/domains/dev.tiki.blue/public_html;
        index index.html index.htm index.php;
        access_log /var/log/virtualmin/dev.tiki.blue_access_log;
        error_log /var/log/virtualmin/dev.tiki.blue_error_log;

        set $skip_cache 0;

        proxy_cache_key "$scheme$request_method$host$request_uri";
        proxy_cache DEVTO;
        proxy_cache_use_stale error updating timeout invalid_header
http_500 http_503;
        proxy_cache_background_update on;
        proxy_cache_lock on;
        proxy_cache_valid 200 301 302 404 5m;
        proxy_buffers 16 16k;
        proxy_buffer_size 32k;
        proxy_ignore_headers Cache-Control Expires Set-Cookie;
        proxy_cache_bypass $skip_cache;
        proxy_no_cache $skip_cache;

        location / {
                expires 10m;
                add_header X-Cache $upstream_cache_status;
                add_header Last-Modified $upstream_http_date;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host "dev.tiki.org";
                proxy_set_header Accept-Encoding "";
                proxy_redirect ~^https?://dev\.tiki\.org(/.*)
$scheme://$server_name$1;
                proxy_pass https://dev.tiki.org;
                subs_filter "https?://dev.tiki.org" "https://dev.tiki.blue"
gr;
        }

        location = /tiki-login_scr.php {
                return 403;
        }
        location = /tiki-login.php {
                return 403;
        }

        ssl_certificate /home/tiki/domains/dev.tiki.blue/ssl.combined;
        ssl_certificate_key /home/tiki/domains/dev.tiki.blue/ssl.key;
}

_______________________________________________
TikiWiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.