Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

434
Views
Apache Virtual Host Reverse Proxy Specific URL: How to correctly cache on local server and client?

I posted this question on the Apache httpd-users mailing list a week ago, no response there. Since then, I've done a bit more work, so I hope I can get some help here, thanks!

In my Apache Virtual Host, I have a working reverse proxy for specific URLs. My use case: I use plausible.io for privacy-respecting web stats. See Plausible's discussion of the need for the proxy. Here's that part of my config:

SSLProxyEngine on
ProxyPass "/api/event" "https://plausible.io/api/event"
ProxyPass "/p.js" "https://plausible.io/js/plausible.js"

Here's the location on my web site, serving the Javascript from Plausible: https://pseud.ony.ms/p.js

The response includes:

cache-control: max-age=0, private, must-revalidate

Now I'd like to work out how to configure my local server to cache the Javascript file and serve it with appropriate headers, like Expires, Last-Modified, Cache-Control, etc., and respond 304 when appropriate.

I've consulted the Apache documentation and read some cookbook articles on reverse proxies and caching with Apache, including:

  • https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
  • https://taylor.callsen.me/creating-a-caching-proxy-server-with-apache/

But those describe a server where everything is reverse-proxied. I want to proxy and cache only these few locations.

I spent some time coming up with these directives in my virtual host (not active as I write this, since they don't work):

ExpiresActive On
ExpiresByType application/javascript "access plus 1 years"
# CacheRoot directory created by a2enmod cache_disk
CacheRoot /var/cache/apache2
CacheQuickHandler off
CacheLock on
CacheLockPath /tmp/mod_cache-lock
CacheLockMaxAge 5
CacheIgnoreCacheControl On
CacheHeader On
Header unset Expires
Header unset Cache-Control
Header unset Pragma
CacheEnable disk /p.js

SSLProxyEngine on
ProxyPass "/api/event" "https://plausible.io/api/event"
ProxyPass "/p.js" "https://plausible.io/js/plausible.js"

With those directive activated, the response loses the Cache-Control header and now includes:

X-Cache: MISS from pseud.ony.ms

Even when I refresh the browser, which is when I'd like to see a 304 response or at least a cache hit.

Oh, and is there a way I can confirm Apache is sending X-Forwarded-For to Plausible, so they can geolocate the IP address correctly?

Thanks!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!