I use server management software plesk with apache and nginx. I set in apache and nginx a expired header for javascript files for one year. That's working. I can see one year for "expires" in header.
Now I want access javascript and php files with a rewrite (without redirect).
APACHE
ExpiresActive On
ExpiresByType text/javascript A31556952
RewriteEngine On
RewriteRule fake/(.+\.(?:js|php))$ original/$1 [L]
NGINX
location ~* ^/(.*\.js)$ {
try_files $uri @fallback;
expires 1y;
add_header Cache-Control "public";
}
That RewriteRule is working. I can access this files, but the "expires" header in "fake/file.js" is gone. What am I doing wrong?
example.com/original/file.js = expires in one year
example.com/fake/file.js = no header for expires
SOLUTION All static files are normally processing by NGINX, not apache. So set in apache this line for javascript give it a cache.
Header set Cache-Control "max-age=31556952, public"
Flag [L] in RewriteRule must stop static files processing by nginx and ExpiresByType is ignored.