[Answered ]-Can't set expire header on images with Apache

2πŸ‘

βœ…

It looks the twitter.png file gets a 404:

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html
Date: Sun, 06 Nov 2016 06:44:39 GMT
Server: nginx
Vary: Accept-Encoding

Here’s a modified version of the solution by Nicholas Kuechler

location ~* \.(png|jpe?g|gif|ico|tiff)$ {
  expires max;
  log_not_found off;
  access_log off;
}

If it’s getting 404, you likely have the root directive incorrectly setup for location-block inheritance. Confirm that the root (DocumentRoot) is correct, and that the file exists relative to the root path, and it should show.

πŸ‘€Zach

0πŸ‘

You could also follow this guide for uWSGI and NGINX to replace apache, and set up static files as an alias in a location block instead, and add the headers from my previous answer.

http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

πŸ‘€Zach

Leave a comment