Welcome! Log In Create A New Profile

Advanced

proxy_cache

June 29, 2016 06:05AM
Доброго дня!
Имеется nginx(frontend) apache (backend)
делаю кэширование на nginx для ускорения работы сайта ибо сейчас ttfb от 2 сек и выше.
вот мои конфиги

nginx.conf
user www-data;
worker_processes auto;
timer_resolution 100ms;
worker_priority -5;

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

pid /var/run/nginx.pid;

events {
# accept_mutex on;
# accept_mutex_delay 500ms;
# worker_aio_requests 32
use epoll;
worker_connections 2048;
multi_accept on;
}

http {
# Подключение mimetypes
include /etc/nginx/mime.types;

# Подключение прокси
include /etc/nginx/proxy_params;

# Не показывать информацию о сервере
server_tokens off;

# Логи доступа
access_log /var/log/nginx/access.log;
#access_log off;

# Протокол отдачи статики
sendfile on;

tcp_nodelay on;
tcp_nopush on;

# Подключение других настроек
include /etc/nginx/conf.d/*.conf;

# Подключение виртуальных хостов
include /etc/nginx/sites-enabled/multiblender.ru;
}

proxy_param.conf


# Базовые настройки
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Защита от killapache.pl
proxy_set_header Range "";
proxy_set_header Request-Range "";

# Размер буферов
proxy_buffers 32 8k; # 256K * 4096 = ~1G
proxy_buffering on;


proxy_ignore_client_abort off;
proxy_intercept_errors off;
proxy_read_timeout 320s;

core_module.conf


chunked_transfer_encoding on;
client_body_buffer_size 32k; # стандартный буфер для обычных POST
client_max_body_size 64m; # максимальный буфер для больших файлов не больше чем у PHP
client_body_in_file_only off;
#client_body_in_single_buffer off;
client_header_buffer_size 1k; # Маленький входной буфер
large_client_header_buffers 4 8k; # Максимальный буфер равен входному буферу apache и PHP
#client_header_timeout 60s;
client_body_timeout 10;
client_header_timeout 10;

default_type application/octet-stream;

#directio off;
#disable_symlinks off;
#if_modified_since exact;
ignore_invalid_headers on;
underscores_in_headers on;

keepalive_disable msie6;
keepalive_requests 100;
keepalive_timeout 30;

# таймаут при передаче клиентам
send_timeout 2;
reset_timedout_connection on;

# Ограничение скорости!!!
#limit_rate 0;
#limit_rate_after 0;

# Интересное кеширование информации о мелких файлах
open_file_cache max=4096 inactive=20s;
open_file_cache_valid 40s;
open_file_cache_min_uses 2;
open_file_cache_errors on;


gzip_module.conf


gzip on;
gzip_buffers 32 8k;
gzip_comp_level 1;
gzip_disable msie6;
gzip_min_length 20;
gzip_http_version 1.1;
gzip_proxied off;
gzip_types text/plain application/xml application/x-javascript application/javascript text/javascript text/xml ext/javascript text/css text/json application/vnd.ms-excel application/vnd.ms-powerpoint application/msword;
gzip_vary off;


site_enable

proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=cache:10m inactive=60m;
proxy_set_header Accept-Encoding "";
#proxy_temp_path /var/nginx/proxy 1 2;

proxy_ignore_headers Expires Cache-Control;
proxy_cache_use_stale error timeout invalid_header http_502;
proxy_cache_bypass $cookie_session;
proxy_no_cache $cookie_session;

proxy_ignore_headers Set-Cookie;
server {
listen 80;
server_name multiblender.ru www.multiblender.ru;
log_format cache_status '[$time_local] "$request" $upstream_cache_status';
access_log /var/log/cache.log cache_status;

access_log /var/log/nginx-access.log;
error_log /var/log/nginx-error.log;

root /var/www/html/;
index index.php index.html index.htm;

tcp_nodelay on;
tcp_nopush on;

location / {
sub_filter_once off;
sub_filter '="aaa' '="bbb';
proxy_cache cache;
proxy_ignore_headers Expires;
proxy_ignore_headers Cache-Control;
proxy_cache_valid any 30m;

proxy_cache_valid 404 502 503 1m;
proxy_cache_key $host$uri$request_uri$is_args$args;
proxy_cache_bypass $cookie_pass_hash;
proxy_no_cache $cookie_pass_hash;
add_header X-Cache-Status $upstream_cache_status;

proxy_pass http://127.0.0.1:8080/;

}

location ~* ^.+\.(html|xhtml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|js|wmv|avi|cur|swf|mp3|wma|htc|cur|7z)$
{
root /var/www/html;
expires 3d;
add_header Cache-Control "public";
}

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


# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

# location ~ \.(jpg|jpeg|gif|png|ico|css|bmp|swf|js|mov|avi|mp4|mpeg4) {
# root /var/www/html;
# }

location ~ /.ht {
deny all;
}
}




На данный момент файлики кэша создаются в директории.

В логах такая фигня


[29/Jun/2016:10:03:55 +0000] "GET /mojka-kuppersberg-modena-15b-sand HTTP/1.1" MISS
[29/Jun/2016:10:03:57 +0000] "GET /vstraivaemaja-bytovaja-tehnika/duhovye-shkafy/proizvoditel:beko,bosch,electrolux,indesit,zanussi,neff,hotpoint-ariston,samsung/sklad:in/tsvet:seryj,chernyj/duhovka:elektricheskaja-nezavisimaja,gazovaja-nezavisimaja/ HTTP/1.1" MISS
[29/Jun/2016:10:04:09 +0000] "GET /varochnaya-poverhnost-gorenje-g6n4zbb HTTP/1.1" MISS
[29/Jun/2016:10:04:27 +0000] "GET /varochnaya-panel-neff-t43d49n2 HTTP/1.1" MISS

[29/Jun/2016:09:50:42 +0000] "GET /image/cache/data/mx/zadacha/p26103_346693_stiralnaya_mashina_samsung_wf8590nmw9-250x250.jpg HTTP/1.1" -
[29/Jun/2016:09:50:42 +0000] "GET /image/cache/data/mx/zadacha/p52000_4324919_stiralnaya_mashina_samsung_wf60f1r0f2w-250x250.jpg HTTP/1.1" -
[29/Jun/2016:09:50:42 +0000] "GET /image/cache/data/mx/zadacha/p52116_4355360_morozilnik_kraft_xf_300a-250x250.jpg HTTP/1.1" -
[29/Jun/2016:09:50:42 +0000] "GET /catalog/view/theme/lexus_happycook/stylesheet/sliderlayer/assets/btn-slide.png HTTP/1.1" -

Тоесть ничего не кэшируется, помогите кто шарит хорошо.
Subject Author Posted

proxy_cache

tirael June 29, 2016 06:05AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready