Webp nginx对wordpress的支持

时间:2019-06-07 23:03:32

标签: wordpress nginx webp

嗨,我正在尝试为Nginx wordpress网站实现Webp支持。

并遵循本指南https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website 要将图像转换为webp格式,我看到.webp

中所有具有重复文件的图像

已添加 图像/ WebP WebP;到/etc/nginx/mime.types; 我已经添加到主要的nginx.conf

   
	#Add this block, before the server directive.
	#This mapping checks whether the browser client supports WebP images, 
	#when it does it will set WebP image files as default source.
	map $http_accept $webp_suffix {
    default   "";
    "~*webp"  ".webp";
	}

**Also added below to the sververblock**

location ~* ^(/wp-content/.+)\.(jpe?g|png) {
  add_header Cache-Control "public, no-transform";
  add_header Vary Accept;
  try_files $1$webp_suffix $uri =404;
  expires max;
}
但是,如何检查一切正常?当我在Google Developer工具中加载页面时,图像仍显示内容类型:image / jpeg而不应该是image / webp吗?

0 个答案:

没有答案