Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting expires header for a specific URI?

I'm trying to set expire header for a specific URI but for some reason it is not working, what I've done so far in the httpd.conf file was the following:

<LocationMatch "/mysite/contentservices/weather/get.json">
  ExpiresDefault A86400
</LocationMatch>

<LocationMatch "/mysite/*">
  Options FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  Allow from all
  ExpiresByType text/css "access plus 1 day"
  ExpiresByType text/javascript "access plus 1 day"
  ExpiresByType image/gif "access plus 1 week"
  ExpiresByType image/jpg "access plus 1 week"
  ExpiresByType image/png "access plus 1 week"
  ExpiresByType application/x-shockwave-flash "access plus 1 week"
</LocationMatch>

This simply does not work for me. I get no expiry date headers for the contents I specified. I also don't understand what exactly happens when you have two LocationMatch directives that overlap that the first one takes precedence?

like image 894
Yaniv Cohen Avatar asked Oct 14 '22 13:10

Yaniv Cohen


2 Answers

I'm not sure but the docs do not mention LocationMatch as possible context.

"Context: server config, virtual host, directory, .htaccess"

http://httpd.apache.org/docs/2.0/mod/mod_expires.html

like image 186
Mr. Ronald Avatar answered Oct 19 '22 01:10

Mr. Ronald


I assume that /mysite/contentservices/weather/get.json is a static data file and NOT served up by CGI / mod_php / something else?

The configs are applied in the order in which they are found in the config file.

See http://httpd.apache.org/docs/2.0/sections.html

Although given no other factors the different formatting of the argument shouldn't be a problem, it might be worth checking what happens if you try:

<LocationMatch "/mysite/contentservices/weather/get.json">
  ExpiresDefault "access plus 1 day"
</LocationMatch>

C.

like image 30
symcbean Avatar answered Oct 19 '22 01:10

symcbean