logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache configuration directives precedence
Author
GoofyX



Joined: 13 Jan 2020
Posts: 6
Location: Greece

PostPosted: Mon 13 Jan '20 20:40    Post subject: Apache configuration directives precedence Reply with quote

Hi people, this is my first post in the forum.

I maintain my VPS, which serves as a web server. It runs Apache 2.4 and in httpd.conf I have these directives (in that order):

Code:
Include /etc/apache2/modules.d/*.conf
Include /etc/apache2/vhosts.d/*.conf


Inside /etc/apache2/modules.d/ there's a conf file with this content:

Code:
<IfModule mod_expires.c>

    ExpiresActive on
    ExpiresDefault                                      "access plus 1 month"

    ExpiresByType application/javascript                "access plus 1 month"
    ExpiresByType application/x-javascript              "access plus 1 month"
    ExpiresByType text/javascript                       "access plus 1 month"

</IfModule>


Inside /etc/apache2/vhosts.d, there's a vhost configuration file, where I have:

Code:
<VirtualHost *:443>
    <IfModule mod_expires.c>
        <LocationMatch "^/(piwik|matomo)\.js$">
            ExpiresDefault "access plus 5 days"
        </LocationMatch>
    </IfModule>
</VirtualHost>


Now, when I access piwik.js or matomo.js, it should return a expiring date 5 days later from the accessing time, however it returns a month later.

Why doesn't this LocationMatch directive work and the generic ExpiresByType directive takes precedence? If I change the ExpiresByType text/javascript "access plus 1 month" line to ExpiresByType text/javascript "access plus 1 week", I see that the expiring date is a week later. Shouldn't the LocationMatch directive work and return a small expiring date for these two javascript files?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 17 Jan '20 12:18    Post subject: Reply with quote

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

in other words: it does not work with LocationMatch. You rather use Directory
Back to top
GoofyX



Joined: 13 Jan 2020
Posts: 6
Location: Greece

PostPosted: Fri 17 Jan '20 13:52    Post subject: Reply with quote

Thanks, I will try another way.
Back to top


Reply to topic   Topic: Apache configuration directives precedence View previous topic :: View next topic
Post new topic   Forum Index -> Apache