Laravel Glide - 404访问图像:NGINX缓存问题

时间:2015-08-10 03:11:17

标签: laravel caching nginx laravel-5.1

在我的Laravel 5.1应用程序中,我使用https://github.com/thephpleague/glide调整大小并在调整大小后通过.cache目录提供图像。我遇到了与Laravel Glide not finding images at urls with extension

完全相同的问题

必须在NGINX中禁用缓存:

# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
  expires -1;
  access_log logs/static.log;
}

# Feed
location ~* \.(?:rss|atom)$ {
  expires 1h;
  add_header Cache-Control "public";
}

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
  expires 1M;
  access_log off;
  add_header Cache-Control "public";
}

# CSS and Javascript
location ~* \.(?:css|js)$ {
  expires 1y;
  access_log off;
  add_header Cache-Control "public";
}

# WebFonts
# If you are NOT using cross-domain-fonts.conf, uncomment the following directive
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
 expires 1M;
 access_log off;
 add_header Cache-Control "public";
}

禁用这些规则后,我可以再次访问这些图像。有小费吗?启用此功能后,我仍然可以“看到”图像,但我的服务器无法读取它们。在这里发生的事情有点迷失。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

采取' jpg | jpeg | gif | png |'在你的比赛中,重新启动nginx,清除浏览器缓存。 Glide将为您的图像排序缓存。