Title: browser caching for media
Last modified: January 22, 2019

---

# browser caching for media

 *  Resolved [alexlii](https://wordpress.org/support/users/alexlii/)
 * (@alexlii)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/)
 * Hello,
 * I have add the following lines into nginx.conf:
 *     ```
       ##
           # Follow the steps below to add browser caching to your NGINX server.
           # Copy the generated code into your nginx.conf usually located at /etc/nginx/nginx.conf or /usr/local/nginx/conf/nginx.conf
           # Add the code above to the http or inside server section in the file.
           # Restart NGINX.
           # Re-check expiry status.
           ##
   
       #   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;
       #   }
       ```
   
 * But, it still show “1 of your cache types don’t meet the recommended expiry period
   of 8+ days. Configure browser caching here”
 * please check the screenshot:[http://prntscr.com/magq6i](http://prntscr.com/magq6i)
 * Also, the Current expiry: 10 years
 * We are using Easyengine([https://easyengine.io](https://easyengine.io)), Redis
   cache and Nginx on server, is there any mis configuration please?
 * Thanks and have a nice day.
    -  This topic was modified 7 years, 3 months ago by [alexlii](https://wordpress.org/support/users/alexlii/).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Anton Vanyukov](https://wordpress.org/support/users/vanyukov/)
 * (@vanyukov)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/#post-11116860)
 * Hi [@alexlii](https://wordpress.org/support/users/alexlii/),
 * The code that you posted is commented out. If that’s how you have it in your 
   config, you need to change it to:
 *     ```
          ##
          # Follow the steps below to add browser caching to your NGINX server.
          # Copy the generated code into your nginx.conf usually located at /etc/nginx/nginx.conf or /usr/local/nginx/conf/nginx.conf
          # Add the code above to the http or inside server section in the file.
          # Restart NGINX.
          # Re-check expiry status.
          ##
   
          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;
          }
       ```
   
 *  Thread Starter [alexlii](https://wordpress.org/support/users/alexlii/)
 * (@alexlii)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/#post-11116992)
 * Hello,
 * If they are not commented out, the nginx can not be restart, and it show errors:
 *     ```
       root@101:~# service nginx restart
       Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
       root@101:~# 
       ```
   
 * Here is almost full lines:
 *     ```
           ##
           # Basic Settings
           ##
           # server_names_hash_bucket_size 64;
           # server_name_in_redirect off;
   
           include /etc/nginx/mime.types;
           default_type application/octet-stream;
   
           ##
           # Logging Settings
           # access_log disabled for performance
           ##
   
           access_log off;
           error_log /var/log/nginx/error.log;
   
           # Log format Settings
           log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_status [$time_local] '
           '$http_host "$request" $status $body_bytes_sent '
           '"$http_referer" "$http_user_agent"';
   
           ##
           # Gzip Settings
           ##
   
           gzip on;
           gzip_disable "msie6";
   
           gzip_vary on;
           gzip_proxied any;
           gzip_comp_level 6;
           gzip_buffers 16 8k;
           gzip_http_version 1.1;
           gzip_types
           application/atom+xml
           application/javascript
           application/json
           application/rss+xml
           application/vnd.ms-fontobject
           application/x-font-ttf
           application/x-web-app-manifest+json
           application/xhtml+xml
           application/xml
           font/opentype
           image/svg+xml
           image/x-icon
           text/css
           text/plain
           text/x-component
           text/xml
           text/javascript;
   
           ##
           # Brotli Settings
           ##
   
           brotli on;
           brotli_static on;
           brotli_buffers 16 8k;
           brotli_comp_level 6;
           brotli_types *;
   
           ##
           # Follow the steps below to add browser caching to your NGINX server.
           # Copy the generated code into your nginx.conf usually located at /etc/nginx/nginx.conf or /usr/local/nginx/conf/nginx.conf
           # Add the code above to the http or inside server section in the file.
           # Restart NGINX.
           # Re-check expiry status.
           ##
   
         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;
          }
   
           ##
           # Virtual Host Configs
           ##
           include /etc/nginx/conf.d/*.conf;
           include /etc/nginx/sites-enabled/*;
       }
       ```
   
 *  [Anton Vanyukov](https://wordpress.org/support/users/vanyukov/)
 * (@vanyukov)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/#post-11117303)
 * [@alexlii](https://wordpress.org/support/users/alexlii/),
 * Please try adding it to a site config in /etc/nginx/sites-enabled/
 * Also, what’s the error message
    `systemctl status nginx.service`
 * Best regards,
    Anton
 *  Thread Starter [alexlii](https://wordpress.org/support/users/alexlii/)
 * (@alexlii)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/#post-11117643)
 * Hello,
 * similar setting already set:
 *     ```
           index index.php index.html index.htm;
   
           # Added Later
   
       if ($request_uri ~* "/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*") {
                set $skip_cache 1;
       }
   
           location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       		access_log off;	log_not_found off; expires max;
           }
   
           # End of Added Later
   
           #Added Later redis to redisphp72
   
           include common/redis-php72.conf;     
           include common/wpcommon-php72.conf;
           include common/locations-php72.conf;
           include /var/www/mysite.com/conf/nginx/*.conf;
   
         location /netdata {
               return 301 /netdata/;
          }
   
          location ~ /netdata/(?<ndpath>.*) {
               include common/acl.conf;
               proxy_redirect off;
               proxy_set_header Host $host;
   
               proxy_set_header X-Forwarded-Host $host;
               proxy_set_header X-Forwarded-Server $host;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               proxy_http_version 1.1;
               proxy_pass_request_headers on;
               proxy_set_header Connection "keep-alive";
               proxy_store off;
               proxy_pass http://netdata/$ndpath$is_args$args;
   
               gzip on;
               gzip_proxied any;
               gzip_types *;
           }
       ```
   
 * so, is it necessary to add your line still?
 * If not, how to make Hummingbird know the exist setting?
 * Thanks
 *  [Anton Vanyukov](https://wordpress.org/support/users/vanyukov/)
 * (@vanyukov)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/#post-11117681)
 * [@alexlii](https://wordpress.org/support/users/alexlii/),
 * Setting **expires max** is equivalent to the 10 years expiry that Hummingbird
   is showing. You can either replace that value, or keep it.
 * Also, add pdf to the list. For example,
 *     ```
           location ~* ^.+\.(pdf|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
       		access_log off;	log_not_found off; expires 8d;
           }
       ```
   
 * Best regards,
    Anton
 *  Plugin Support [Dimitris – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support6/)
 * (@wpmudev-support6)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/#post-11185509)
 * Hello [@alexlii](https://wordpress.org/support/users/alexlii/),
 * it’s been a while since we’ve heard back from you, so I’m marking this topic 
   as resolved. Feel free to post back and we can re-open it. 🙂
 * Take care,
    Dimitris

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘browser caching for media’ is closed to new replies.

 * ![](https://ps.w.org/hummingbird-performance/assets/icon-256x256.gif?rev=2633221)
 * [Hummingbird Performance - Cache & Page Speed Optimization for Core Web Vitals | Critical CSS | Minify CSS | Defer CSS Javascript | CDN](https://wordpress.org/plugins/hummingbird-performance/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/hummingbird-performance/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/hummingbird-performance/)
 * [Active Topics](https://wordpress.org/support/plugin/hummingbird-performance/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/hummingbird-performance/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/hummingbird-performance/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Dimitris – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support6/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/browser-caching-for-media/#post-11185509)
 * Status: resolved