Cloudkul Support

How to use Nginx as a Caching Server ?

Go to /etc/nginx/nginx.conf and add the line

proxy_cache_path /tmp/cache keys_zone=mycache:10m levels=1:2 inactive=600s max_size=100m;

/tmp/cache => where cache files will be stored
keys_zone => cache name
inactive => Expire time of cache
max_size => Maximum size of cache

Suppose we want to cache the url “/products”, we need to add some lines in location directive

location /products {
proxy_cache mycache; #cache name defined earlier
proxy_cache_valid 200 30s; # cache is valid for http status 200 and for 30 seconds
}

 

Is this article is helpful?

People like and 0 people dislike.

If result is not found or irrelevant, Please contact us.

Submit your request

Start a Project






    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home