Load static content directly thru Nginx

Everytime your wordpress blog loads, it is also sending a lot of files that are static e.g. images, CSS, javascript and so on.

In the standard configuration, this is passed thru the PHP process which slows down the delivery as it has to be processed before, even that there is absolutely no reason to do this.

You can avoid this, by configuring NGINX to directly deliver these files and speed everything up.

Add to your https configuration the following line

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

If you have more file types that you want to deliver directly and that are static, add them to js|css|png|jpg|jpeg|gif|ico|woff e.g. js|css|png|jpg|jpeg|gif|ico|woff|pdf

Restart your NGINX and you are good to go.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.