wordpress插件: W3 Total Cache

作者: 麻辣阁 分类: wordpress 发布时间: 2018-11-20 21:57

安装后配置

安装后, wordpress后台提示:

W3 Total Cache Error: Files and directories could not be automatically created to complete the installation.

Please execute commands manually or use FTP form to allow W3 Total Cache make it automatically.

按提示手工创建 /worpress安装目录/nginx.conf 并写入内容:

# BEGIN W3TC Browser Cache
gzip on;
gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint application/x-shockwave-flash image/tiff application/x-font-ttf audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel;
location ~ \.(css|htc|less|js|js2|js3|js4)$ {
    expires 31536000s;
    etag on;
    if_modified_since exact;
    try_files $uri $uri/ $uri.html /index.php?$args;
}
location ~ \.(html|htm|rtf|rtx|svg|txt|xsd|xsl|xml)$ {
    etag on;
    if_modified_since exact;
    try_files $uri $uri/ $uri.html /index.php?$args;
}
location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|_ttf|wav|wma|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|zip)$ {
    expires 31536000s;
    etag on;
    if_modified_since exact;
    try_files $uri $uri/ $uri.html /index.php?$args;
}
location ~ \.(bmp|class|doc|docx|eot|exe|ico|webp|json|mdb|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|pot|pps|ppt|pptx|svg|svgz|swf|tif|tiff|ttf|ttc|_ttf|wav|wri|woff|woff2|xla|xls|xlsx|xlt|xlw)$ {
    etag off;
    if_modified_since off;
    try_files $uri $uri/ $uri.html /index.php?$args;
}
add_header Referrer-Policy "";
# END W3TC Browser Cache

实际上是重写了 nginx 的一些配置, 设置非常详细.

进行其他设置时可能也需要修改该配置文件.

可以安装后访问 Performance : Install 按相关建议继续设置

1.Set the permissions of wp-content/ back to 755, e.g.:

# chmod 755 /var/www/vhosts/domain.com/httpdocs/wp-content/

2.On the “General” tab and select your caching methods for page, database and minify. In most cases,

  • “disk enhanced” mode for page cache,
  • “disk” mode for minify
  • and “disk” mode for database caching are “good” settings.

问题

W3 Total Cache 会做很多自动优化, 包括针对 javascript 等引入的位置调整, 这有时候会带来布局等问题.

即使你不用 W3 Total Cache, 其自动生成的规则依然是直接参考的.


发表评论

电子邮件地址不会被公开。 必填项已用*标注