Welcome! Log In Create A New Profile

Advanced

Microcache : empty pages ?

Ronald Van Assche
August 13, 2014 05:40PM
I have somme strange comportement on nginx 1.7.4 / Freebsd 9 : Some Wordpress microcached pages rendered ..EMPTY HTML pages , for about 1/20 visitors .
When it happens, we have to make a forced reload of the page on the navigator (Firefox or others).

configure arguments: --prefix=/usr/local/etc/nginx --with-cc-opt='-I /usr/local/include' --with-ld-opt='-L /usr/local/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx --pid-path=/var/run/nginx.pid --error-log-path=/var/log/nginx-error.log --user=www --group=www --with-file-aio --with-ipv6 --http-client-body-temp-path=/var/tmp/nginx/client_body_temp --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp --http-proxy-temp-path=/var/tmp/nginx/proxy_temp --http-scgi-temp-path=/var/tmp/nginx/scgi_temp --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi_temp --http-log-path=/var/log/nginx-access.log --add-module=/usr/ports/www/nginx-devel/work/ngx_cache_purge-2.1 --with-http_geoip_module --with-http_stub_status_module --with-pcre

sendfile(/cache/nginx/8/f2/fa48a21dcdf1f2a9ff3d8215b0ab4f28) returned busy again


nginx.conf

user www;
worker_processes 4;
events {
worker_connections 2048;
multi_accept on;
}

http {
include mime.types;
default_type application/octet-stream;

fastcgi_cache_path /cache/nginx levels=1:2 keys_zone=microcache:5m max_size=1000m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

log_format cache_log '$remote_addr - $remote_user [$time_local] "$request" ' '$status $upstream_cache_status $body_bytes_sent "$http_referer" ' '" $http_user_agent" "$http_x_forwarded_for"';

sendfile on;
sendfile_max_chunk 512K;
aio sendfile;
tcp_nopush on;
read_ahead 256K;

open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

keepalive_timeout 120;
keepalive_requests 10000;

client_max_body_size 99M;

gzip on;
gzip_buffers 48 8k;
gzip_comp_level 4;
gzip_http_version 1.0;
gzip_vary on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

error_log /var/log/nginx/nginx.error.log;


geoip_country /usr/local/etc/nginx/geoip/GeoIP.dat; # the country IP database
geoip_city /usr/local/etc/nginx/geoip/GeoLiteCity.dat; # the city IP database


}



The config file for this site =

server {
server_name mobi.********.net *******.mobi ****** net www.********.net ;
# listen 80 accept_filter=httpready sndbuf=32K ;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
access_log /var/log/nginx/******.access.log cache_log;
error_log /var/log/nginx/******.error.log;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
root /home/www/api/wordpress;
index index.php index.html;
rewrite ^/?feed/rss2$ /?feed=rss2 permanent;
try_files $uri $uri/ /index.php;
# this serves static files that exist without running other rewrite tests
if (-f $request_filename) {
expires 30d;
break;
}
# this sends all non-existing file or directory requests to index.php
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
location ~ \.php$ {

set $no_cache '0';
# If non GET/HEAD, don't cache & mark user as uncacheable for 1 second via cookie
if ($request_method !~ ^(GET|HEAD)$) {
set $no_cache '1';
}
# Drop no cache cookie if need be
# (for some reason, add_header fails if included in prior if-block)
if ($no_cache = '1') {
add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
add_header X-Microcachable "0";
}
# Bypass cache if no-cache cookie is set
if ($http_cookie ~* "_mcnc") {
set $no_cache '1';
}
# Bypass cache if Iphone
if ($http_user_agent ~ (iPhone|Android) ) {
set $no_cache '1';
}

if ( $http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
set $no_cache '1';
}

#Don't cache the following URLs
if ($request_uri ~* "/(wp-admin/|wp-login.php)")
{
set $no_cache '1';
}

# Bypass cache if flag is set
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $no_cache "1";
}


# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $no_cache '1';
}

add_header X-Cache $upstream_cache_status;

location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires 7d;
}

########

fastcgi_no_cache $no_cache;
fastcgi_cache_bypass $no_cache;
fastcgi_cache microcache;
fastcgi_cache_key $server_name|$request_uri;

fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1d;
fastcgi_cache_min_uses 1;

fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_cache_bypass $http_pragma;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/www/api/wordpress/$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 120;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 8k;
fastcgi_busy_buffers_size 256k;
# all replies that are greater than the FastCGI buffers and transfer data synchronously to the client set fastcgi_max_temp_file_size to 0
fastcgi_max_temp_file_size 0;
fastcgi_temp_file_write_size 1024k;
include fastcgi_params;
}


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

Microcache : empty pages ?

Ronald Van Assche August 13, 2014 05:40PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 77
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