While serving static content from a server to browser If performance is very slow, we can optimize it by implementing below 2 methods.
1. Enable GZIP compression which will serve files of the specified format by zipping it between server and browser. This minimizes web serving time.
2. Enable images caching to 6 days or more If you want NGINX to cache images in it and serve faster.
Let’s see how can we achieve both of above.
In your default NGINX configuration file, where all rules are written, check for following
Here in every new location blog, we have added “expires 6d”
It will cache those objects in NGINX after once served, and next time when a request arrives it can serve from caching, thus provide faster results.
It will re-cache after 6 days.
2. To enable gzip compression, add the following file at /etc/nginx/conf.d/gzip.conf directory
It will compress content of above-mentioned content types when communicating between server and browser, thus serves faster with compression applied.
Do try to apply this and let us know how much faster results you were able to get! Do Comment below.