Answer the question
In order to leave comments, you need to log in
How to flush cache without reloading nginx?
I cached blogs on WordPress like this:
user www-data;
worker_processes 2;
error_log /web/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /web/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 650;
server_tokens off;
client_max_body_size 80m;
#client_body_buffer_size 128k;
charset utf-8;
gzip_types text/plain application/xml application/x-javascript text/javascript text/css text/json;
gzip on;
server_names_hash_bucket_size 64;
proxy_cache_path /var/cache/pages levels=1:2 keys_zone=czone:4m max_size=50m inactive=120m;
fastcgi_cache_path /var/cache/fpm levels=1:2 keys_zone=fcgi:100m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
include /etc/nginx/sites-enabled/*;
include /etc/nginx/conf.d/*.conf;
}
server
{
server_name site.ru www.site.ru;
access_log /web/log/nginx/site.ru.access.log;
error_log /web/log/nginx/site.ru.error.log;
root /web/site.ru;
index index.php index.html index.htm;
# enforce www (exclude certain subdomains)
#if ($host !~* ^(www|subdomain))
#{
# rewrite ^/(.*)$ $scheme://www.$host/$1 permanent;
#}
# enforce NO www
if ($host ~* ^www\.(.*))
{
set $host_without_www $1;
rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}
# unless the request is for a valid file, send to bootstrap
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
# catch all
error_page 404 /index.php;
# use fastcgi for all php files
location ~ .(php|html)$
{
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache fcgi;
fastcgi_cache_valid 200 60m;
fastcgi_pass_header "X-Accel-Redirect";
fastcgi_pass_header "X-Accel-Expires";
}
# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|pdf|ppt|txt|bmp|rtf|js)$ {
expires 10d;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question