Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Plesk 12 / NGINX – Setting Expires

Setting up expires on Plesk is a little bit tricky, if you’re like us, under the Nginx settings in domains you’ll have Serve static files directly by nginx enabled, at the same time the extensions included will have the extensions you want to set expires for. What happens is, if you’re setting expires for say jpg, nginx will stop at the very first block which specified the extension jpg. Under this scenario, the default Plesk config for the extension jpg will not have the expires directive and neither can you cleanly edit it to set it.

So what do you do? Remove the extension you want to set extra directives for from that section.

Just for note keeping sake, the following is the location block that worked for us and is pretty generic:

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 30d;

A big shout out to Jensen for this find: