Topic: How to enable Cache in Nginx plugin

You can enable caching of static and dynamic files in Nginx plugins easily . It  need to do the following two steps .

Step 1:  You need to edit Nginx main configuration file   from the plugin page and add the following lines.

proxy_cache_path   /usr/local/nginx/proxy_cache   levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path    /usr/local/nginx/proxy_temp ;

Step  2: Edit the vhost configuration from the plugin page and add the following lines.


proxy_cache my-cache;
proxy_cache_valid  200 302  60m;
proxy_cache_valid  404      1m;

Now rebuild nginx vhost and restart .   Please note , you need good amount of free space to hold the cache files.

Syslint Technologies | 24x7 Server Management | Outsourced Support | Software Development - (0091) 471-3273-211

Re: How to enable Cache in Nginx plugin

A sample main nginx.conf after adding this value

# cPanel Nginx Master configuration
user  nobody;
error_log  logs/error.log;
#Number of worker you need
worker_processes  5;
# How many connections a worker can handle maximum.
events {
    worker_connections  1024;
}
http {
        include    mime.types;
        default_type  application/octet-stream;
        sendfile on;
        server_names_hash_max_size 5000;
        server_names_hash_bucket_size 128;
        client_header_buffer_size 16k;
        large_client_header_buffers 16 16k;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout  0;
        gzip on;
        gzip_min_length  1100;
        gzip_buffers  4 32k;
        gzip_types    text/plain  application/x-javascript text/xml text/css;
        ignore_invalid_headers on;
        client_header_timeout  3m;
        client_body_timeout 3m;
        send_timeout     3m;
        proxy_cache_path   /usr/local/nginx/proxy_cache   levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
        proxy_temp_path    /usr/local/nginx/proxy_temp ;
        include "/usr/local/nginx/conf/vhost.conf";
        include "/etc/cpnginx/cpanelproxy.conf";

Syslint Technologies | 24x7 Server Management | Outsourced Support | Software Development - (0091) 471-3273-211

Re: How to enable Cache in Nginx plugin

A sample  vhost template after adding the  vhost entry ,


client_max_body_size    10m;                                                                                                                                                                                                     
client_body_buffer_size 128k;
proxy_send_timeout   90;
proxy_read_timeout   90;
proxy_buffer_size    4k;
proxy_buffers     16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_cache my-cache;
proxy_cache_valid  200 302  60m;
proxy_cache_valid  404      1m;

Syslint Technologies | 24x7 Server Management | Outsourced Support | Software Development - (0091) 471-3273-211

Re: How to enable Cache in Nginx plugin

What is the best way to clear the cache?
Is there a way to exclude some files or directories or cpanel from being cached?

Re: How to enable Cache in Nginx plugin

You can exclude a domain from the  cache. Please enable that domain in direct push so it won't cache .

Syslint Technologies | 24x7 Server Management | Outsourced Support | Software Development - (0091) 471-3273-211

Re: How to enable Cache in Nginx plugin

hello
domain were replaced with time. For example, when we open the domain x domain y is shown. Were moved to domain. What is the problem?
The domain will change with time. Shifts are open.

We had a problem with nginx last night . it was like nothing that i seen befor . when we tried to open domain1.com , that domain will shown domain2.com data ! its like we requested to view domain2.com but we tried to open domain1.com ! Is there any explaination for this matter ? is there any way to find out how to fix this problem ?

Re: How to enable Cache in Nginx plugin

which period of time Cache