[Hummingbird] Browser Caching

Trying to enable browser caching on NGINX. I entered the generated code as shown below into the nginx.conf file. But get the following error when I try to restart nginx:
Unable to restart service: Unable to manage service by nginx_control: ('restart', 'nginx':wink:. Error: /opt/psa/admin/sbin/nginx-config execution failed: nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:81 nginx: configuration file /etc/nginx/nginx.conf test failed

Here is the generated code:

location ~* \.(txt|xml|js)$ {
expires 8d;
}

location ~* \.(css)$ {
expires 8d;
}

location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$ {
expires 8d;
}

location ~* \.(jpg|jpeg|png|gif|swf|webp)$ {
expires 8d;
}

Please advise ASAP.

Oh, and whu is your 24/7 chat support unavailable?

  • wolf Bishop
    • WPTopHat.com

    Here is the nginx.conf

    #user nginx;
    worker_processes 1;

    #error_log /var/log/nginx/error.log;
    #error_log /var/log/nginx/error.log notice;
    #error_log /var/log/nginx/error.log info;

    #pid /var/run/nginx.pid;

    include /etc/nginx/modules.conf.d/*.conf;

    events {
    worker_connections 1024;
    }

    http {
    include mime.types;
    default_type application/octet-stream;

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    # '$status $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log /var/log/nginx/access.log main;

    sendfile on;
    #tcp_nopush on;

    http {
    include mime.types;
    default_type application/octet-stream;

    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    # '$status $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log /var/log/nginx/access.log main;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;
    #tcp_nodelay on;

    #gzip on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;

    }

    # override global parameters e.g. worker_rlimit_nofile
    include /etc/nginx/*global_params;

  • Nithin
    • Support Wizard

    Hi wolf Bishop,

    Hope you are doing good today. :slight_smile:

    A "location" directive can only reside inside a server block. So you'd need to add the browser caching rule as:

    server {
    your_Hummingbird_code_goes_here
     }

    If the above shared conf is the full content of your nginx.conf file, then you can add a new server block as mentioned above in your nginx.conf file, after the http {} block.

    Please let us know how that goes. Have a nice day ahead. :slight_smile:

    Regards,
    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.