• Resolved insanity2k14

    (@insanity2k14)


    Proxy runs apache with mod_proxy. I have my VirtualHosts identified and SiteA is proxied to ServerA, SiteB to ServerB, etc. Reverse proxy has been working without issue for years. In trying to make use of browser caching I’m running into a roadblock. I’ve pieced together the various solutions I’ve been able to find but it’s still not working. On Proxy I have added the following in httpd.conf to try and enable browser caching at this layer:

    <LocationMatch .*\.nocache\..*>
    ExpiresActive On
    ExpiresDefault “access”
    </LocationMatch>

    <LocationMatch .*\.cache\..*>
    ExpiresActive On
    ExpiresDefault “now plus 1 year”
    </LocationMatch>

    Previous to that I tried the following with no success:

    <Files *.nocache.*>
    ExpiresActive On
    ExpiresDefault “access”
    </Files>

    <Files *.cache.*>
    ExpiresActive On
    ExpiresDefault “now plus 1 year”
    </Files>

    On ServerA I have the following in /var/www/html/.htaccess:

    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg “access plus 1 year”
    ExpiresByType image/jpeg “access plus 1 year”
    ExpiresByType image/gif “access plus 1 year”
    ExpiresByType image/png “access plus 1 year”
    ExpiresByType text/css “access plus 1 month”
    ExpiresByType application/pdf “access plus 1 month”
    ExpiresByType text/x-javascript “access plus 1 month”
    ExpiresByType application/x-shockwave-flash “access plus 1 month”
    ExpiresByType image/x-icon “access plus 1 year”
    ExpiresDefault “access plus 2 days”
    </IfModule>
    ## EXPIRES CACHING ##

    To the best of my knowledge Proxy has the correct configurations in httpd.conf to permit browser caching as does the .htaccess file on ServerA where SiteA lives. Testing SiteA with various web tools reports that browser caching is not enabled. I am hoping fervently that someone has experience with this sort of setup and can help point me in the right direction. Thank you in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter insanity2k14

    (@insanity2k14)

    I slapped up a quick test page in /var/www/test on the server I’m referencing above as Proxy. I added the VirtualHost entry for it and then added the following to /var/www/test/.htaccess:

    ## EXPIRES CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg “access plus 1 year”
    ExpiresByType image/jpeg “access plus 1 year”
    ExpiresByType image/gif “access plus 1 year”
    ExpiresByType image/png “access plus 1 year”
    ExpiresByType text/css “access plus 1 month”
    ExpiresByType application/pdf “access plus 1 month”
    ExpiresByType text/x-javascript “access plus 1 month”
    ExpiresByType application/x-shockwave-flash “access plus 1 month”
    ExpiresByType image/x-icon “access plus 1 year”
    ExpiresDefault “access plus 2 days”
    </IfModule>
    ## EXPIRES CACHING ##

    Pingdom’s web tool says browser caching is enabled on this test page. I don’t know if this is helpful or not in figuring out where the problem is.

    Thread Starter insanity2k14

    (@insanity2k14)

    I just tried something I didn’t think to try previously and have resolved this issue. The <IfModule mod_expires.c> block actually goes INSIDE the <VirtualHost> block. I’m good to go. Hopefully this helps someone else someday!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Reverse Proxy and Browser Caching’ is closed to new replies.