之前我有尺寸图像(675 * 774),我用250 * 250的分辨率更新了图像,但它仍然显示旧图像。 https://shop.olamsvi.com/pub/media/catalog/category/Picture1_2.png
当我使用?<random_number>
加载相同的图片时,更新后的图片会显示尺寸(250 * 250)
https://shop.olamsvi.com/pub/media/catalog/category/Picture1_2.png?22
我删除了我的浏览器缓存,并以隐身身份进行了检查。
任何人都可以说明问题所在。
抱歉我的英语不好。
答案 0 :(得分:1)
显然,在Apache服务器前面有Varnish缓存HTTP反向代理,它服务于映像的缓存副本(因为它配置为这样做)。
您可以从HTTP响应标头中观察到:
$ curl -v -s https://shop.olamsvi.com/pub/media/catalog/category/Picture1_2.png -o file.png
* Trying 52.163.125.20...
* TCP_NODELAY set
* Connected to shop.olamsvi.com (52.163.125.20) port 443 (#0)
...
> GET /pub/media/catalog/category/Picture1_2.png HTTP/1.1
> Host: shop.olamsvi.com
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 04 Jun 2018 11:52:41 GMT
< Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips PHP/7.0.21
< Content-Length: 410771
< Accept-Ranges: bytes
< Access-Control-Allow-Origin: *
< X-Frame-Options: SAMEORIGIN
< X-Varnish: 41773
< Age: 0
< Via: 1.1 varnish (Varnish/5.2)
< X-Original-Content-Length: 561788
< Etag: W/"PSA-aj-giNrXrkKdK"
< Expires: Fri, 22 Mar 2019 05:53:09 GMT
< Cache-Control: max-age=25120827, public
< X-Content-Type-Options: nosniff
< Content-Type: image/png
<
{ [16384 bytes data]
* Connection #0 to host shop.olamsvi.com left intact
不是Via: 1.1 varnish (Varnish/5.2)
和Expires: Fri, 22 Mar 2019 05:53:09 GMT
行。
缓存静态资源通常非常有用,但您还应该考虑how to invalidate it(以及何时执行)的方式
答案 1 :(得分:0)
拜托,你能看到这个答案吗?
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 86400 seconds"
ExpiresByType application/x-javascript "access plus 86400 seconds"
</IfModule>
https://stackoverflow.com/a/13029007/4553685
也许它会帮助你