Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon May 19, 2014 7:31 am 
Offline

Joined: Mon May 19, 2014 7:17 am
Posts: 1
I have a LEMP stack running on my site. The main site is a basic CRUD site, with pages of information, using CodeIgniter as the framework (may change this in future as it's getting old, but it works perfectly fine for now). I also have a Q&A section (similar to a forum) which is more dynamic. I also have some custom editing tools for the main site which are under /admin.

I tried to set up caching in nginx to ease the load, but it's not actually working how it's supposed to. I set it so that the Q&A section wasn't cached and everything else was, but those setting are actually not affecting what is cached at all. It seems like setting up a PHP session prevents nginx caching stuff. A couple of times there have been errors in the Q&A section and those URLs ended up getting cached because the page just displayed an error message and did not start any sessions. Similarly, the /admin area was not included in the caching rules but is still not cached anyway.

So anyway here is my site config:

Code:
server {
  listen 80;
  server_name  example.com;
  access_log   /var/log/nginx/example.com/access.log custom;
  error_log    /var/log/nginx/example.com/error.log;
  root         /srv/www/example.com/web;

  limit_conn conn_limit_per_ip 10;
  limit_req zone=req_limit_per_ip burst=10 nodelay;

  index index.php index.html;

  set $no_cache "";

  # QA section
  location /qa/ {
    set $no_cache "1";
    if (!-e $request_filename) {
      rewrite ^/qa/(.*)$ /qa/index.php?qa-rewrite=$1 last;
    }
  }

  # CodeIgniter rewriting
  location / {
    try_files $uri /index.php?$request_uri;
  }

  location ~ \.php$ {
    try_files $uri =404;

    fastcgi_cache one;
    fastcgi_cache_key $scheme$host$request_uri;
    fastcgi_cache_valid  200 302 304 20m;
    fastcgi_cache_valid  301 12h;

    fastcgi_cache_bypass $no_cache;
    fastcgi_no_cache $no_cache;

    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/var/run/php-fastcgi/php-fastcgi.socket;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/www/example.com/web$fastcgi_script_name;
    fastcgi_param HTTPS off;
  }
}



What am I doing wrong?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group