Php Magento防止清漆缓存页
如果您将标题更改为Php Magento防止清漆缓存页,php,magento,caching,nginx,varnish,Php,Magento,Caching,Nginx,Varnish,如果您将标题更改为标题('Cache-Control:public,max age=10'),则Varnish的工作效果非常理想 但是Magento用自己的头覆盖头:缓存控制:无存储,无缓存,必须重新验证,后检查=0,预检查=0,s-maxage=86400 导致从不缓存页面。但您也不希望Varnish缓存登录的用户。。。那么,我应该如何配置Varnish和/或Magento来缓存需要缓存的内容呢 清漆4.0(4.0.3-1) PHP 5.6(5.6.24-1) Nginx 1.0.15(1.0
标题('Cache-Control:public,max age=10'),则Varnish的工作效果非常理想代码>
但是Magento用自己的头覆盖头:缓存控制:无存储,无缓存,必须重新验证,后检查=0,预检查=0,s-maxage=86400
导致从不缓存页面。但您也不希望Varnish缓存登录的用户。。。那么,我应该如何配置Varnish和/或Magento来缓存需要缓存的内容呢
清漆4.0(4.0.3-1)
PHP 5.6(5.6.24-1)
Nginx 1.0.15(1.0.15-12)
Magento 1.9(1.9.2.4)
这是我的HTTP头:
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 08 Aug 2016 08:46:28 GMT
Content-Type: text/html; charset=UTF-8
X-Powered-By: PHP/5.6.24
X-Frame-Options: SAMEORIGIN
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, s-maxage=86400
Expires: Mon, 31 Mar 2008 10:00:00 GMT
Pragma: no-cache
Content-Encoding: gzip
Vary: Accept-Encoding
X-Varnish: 32770
Age: 0
Via: 1.1 varnish-v4
Content-Length: 0
Connection: keep-alive
我的Varnish vcl配置:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
unset req.http.cookie;
}
sub vcl_backend_response {
unset beresp.http.set-cookie;
}
sub vcl_deliver {
unset resp.http.set-cookie;
}
server {
listen 127.0.0.1:8080;
server_name <my website, www.example.com>;
#charset koi8-r;
#access_log logs/host.access.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /var/www/public_html;
index index.php index.html index.htm;
try_files $uri $uri/ @handler;
}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
# location ~ .php$ { ## Execute PHP scripts
# if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
# root /var/www/public_html;
# expires off; ## Do not cache dynamic content
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
# fastcgi_param MAGE_RUN_TYPE store;
# include fastcgi_params; ## See /etc/nginx/fastcgi_params
# }
location ~ ^(.+\.php)(.*)$ {
root /var/www/public_html;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/public_html/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root /var/www/public_html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我的“nginx.conf”配置
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
server_tokens off;
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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
fastcgi_read_timeout 300;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;
}
我的“default.conf”配置:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
unset req.http.cookie;
}
sub vcl_backend_response {
unset beresp.http.set-cookie;
}
sub vcl_deliver {
unset resp.http.set-cookie;
}
server {
listen 127.0.0.1:8080;
server_name <my website, www.example.com>;
#charset koi8-r;
#access_log logs/host.access.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /var/www/public_html;
index index.php index.html index.htm;
try_files $uri $uri/ @handler;
}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
# location ~ .php$ { ## Execute PHP scripts
# if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
# root /var/www/public_html;
# expires off; ## Do not cache dynamic content
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
# fastcgi_param MAGE_RUN_TYPE store;
# include fastcgi_params; ## See /etc/nginx/fastcgi_params
# }
location ~ ^(.+\.php)(.*)$ {
root /var/www/public_html;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/public_html/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root /var/www/public_html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
服务器{
听127.0.0.1:8080;
服务器名称;
#charset-koi8-r;
#access_log logs/host.access.log main;
#加载默认服务器块的配置文件。
include/etc/nginx/default.d/*.conf;
地点/{
root/var/www/public\u html;
index.php index.html index.htm;
try_files$uri$uri/@handler;
}
##这些位置通常会被.htaccess隐藏
位置^~/app/{deny all;}
位置^~/includes/{deny all;}
位置^~/lib/{deny all;}
位置^~/media/downloadable/{deny all;}
位置^~/pkginfo/{deny all;}
位置^~/report/config.xml{deny all;}
位置^~/var/{deny all;}
location/var/export/{##只允许管理员查看导出文件夹
验证基本“受限”;##消息显示在登录窗口中
验证基本用户文件htpasswd;##请参阅/etc/nginx/htpassword
自动索引;
}
位置/{##禁用.htaccess和其他隐藏文件
返回404;
}
位置@handler{##Magento使用一个公共的前处理程序
重写//index.php;
}
location~.php/{##将类似/js/index.php/x.js的路径转发到相关处理程序
最后重写^(.*.php)/$1;
}
#location~.php${##执行php脚本
#如果(!-e$request_filename){rewrite//index.php last;}##捕获404,则try_文件将丢失
#root/var/www/public\u html;
#过期关闭;##不缓存动态内容
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index.php;
#fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
#fastcgi_参数图像_运行_代码默认值;##存储代码在管理>配置>管理存储中定义
#fastcgi_参数图像运行型存储;
#包括fastcgi_参数;##请参见/etc/nginx/fastcgi_参数
# }
位置~^(+\.php)(.*)${
root/var/www/public\u html;
fastcgi\u split\u path\u info^(+.+\.php)(.*);
fastcgi_pass 127.0.0.1:9000;
fastcgi_index.php;
包括fastcgi_参数;
fastcgi_参数SCRIPT_FILENAME/var/www/public_html/$fastcgi_SCRIPT_name;
fastcgi_参数路径_信息$fastcgi_脚本_名称;
}
错误\u第404/404.html页;
location=/404.html{
root/usr/share/nginx/html;
}
#将服务器错误页面重定向到静态页面/50x.html
#
错误\u第500页502 503 504/50x.html;
location=/50x.html{
root/usr/share/nginx/html;
}
#将PHP脚本代理到Apache,并在127.0.0.1:80上侦听
#
#位置~\.php${
#代理通行证http://127.0.0.1;
#}
#将PHP脚本传递给FastCGI服务器,并在127.0.0.1:9000上侦听
#
#位置~\.php${
#root/var/www/public\u html;
#fastcgi_pass 127.0.0.1:9000;
#fastcgi_index.php;
#fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
#包括fastcgi_参数;
#}
#拒绝访问.htaccess文件,如果Apache的文档根
#同意nginx的观点
#
#位置~/\.ht{
#否认一切;
#}
}
页面上可能存在不可缓存的块。搜索。。。在.*.xml文件中,CaseCyt= =“false”,并考虑使块缓存。
通过运行
bin/magento cache:status
你也可以发布你的nginx配置吗?当然,我现在已经编辑了这篇文章。有人发现了什么吗?你使用的是什么Magento扩展?或者我们使用linux“apt-get”,或者可能是“yum”,并安装了清漆