django - Can't set expire header on images with Apache -


i trying tell browsers cache type of image files (png/jpg/gif/etc) application, setting .htaccess file in root of django application.

.htaccess

<ifmodule mod_expires.c>   expiresactive on   expiresdefault "access plus 1 seconds"   expiresbytype image/gif "access plus 365 days"   expiresbytype image/jpeg "access plus 365 days"   expiresbytype image/png "access plus 365 days" </ifmodule> 

apache

loadmodule authz_core_module modules/mod_authz_core.so loadmodule dir_module        modules/mod_dir.so loadmodule env_module        modules/mod_env.so loadmodule log_config_module modules/mod_log_config.so loadmodule mime_module       modules/mod_mime.so loadmodule rewrite_module    modules/mod_rewrite.so loadmodule setenvif_module   modules/mod_setenvif.so loadmodule wsgi_module       modules/mod_wsgi.so loadmodule unixd_module      modules/mod_unixd.so loadmodule expires_module    modules/mod_expires.so loadmodule headers_module    modules/mod_headers.so  <directory />s     allowoverride </directory>  logformat "%{x-forwarded-for}i %l %u %t \"%r\" %>s %b \"%{referer}i\" \"%{user-agent}i\"" combined customlog /home/timbaney1989/logs/user/access_baneydev.log combined errorlog /home/timbaney1989/logs/user/error_baneydev.log 

before adding allowoverride option, getting internal server error, app running fine. when check network , see images being loaded, don't see expire header anywhere on image. server says nginx ? normal thing running application on apache serve, , have nginx server loading static files ? there somewhere in django application or apache httpd.conf file missing, or have entered incorrectly ?

enter image description here

it looks twitter.png file gets 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 modified version of solution nicholas kuechler

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

if it's getting 404, have root directive incorrectly setup location-block inheritance. confirm root (documentroot) correct, , file exists relative root path, , should show.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -