Top Nav

Expires Header In Nginx On Plesk

Trying to add an Expires header in Nginx on a Plesk server like this is problematic.

The “location” directive conflicts (overrides) the “location” directive created by Plesk. The work around is to disable “Serve static files directly by nginx” but this is a valuable feature that we usually don’t want to turn off.

An alternative is to use a “map” directive. Setup the map in the global nginx config by creating /etc/nginx/conf.d/expires_map.conf with:

Next in the “Additional nginx directives” field add:

This works well but may not be possible on a shared server where the global nginx configuration can not be changed.