add_header Pragma public: the standard says for a Cache-Control: public - Indicates that the response MAY be cached by any cache

add_header Cache-Control “public, must-revalidate, proxy-revalidate”;

+ must-revalidate: tells caches that they must obey any freshness information you give them about a representation. HTTP allows caches to serve stale representations under special conditions; by specifying this header, you’re telling the cache that you want it to strictly follow your rules.

proxy-revalidate: similar to must-revalidate, except that it only applies to proxy caches.

Source: https://gist.github.com/philipstanislaus/654adafad91efb6de230845b5bdeae61

Tham khảo Nginx Pitfall and common mistakes: https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/

Tham khảo thêm:

location ~ \.(css|js|htc)$ {
    add_header Pragma "public";
    add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
         log_not_found off;
         access_log off;

}
location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
    add_header Pragma "public";
    add_header Cache-Control "max-age=3600, public, must-revalidate, proxy-revalidate";
         log_not_found off;
        access_log off;

}
location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mp
e|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$
 {
    add_header Pragma "public";
    add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
         log_not_found off;
         access_log off;

}

We use this on a very busy site with very good effect.

Source: https://serverfault.com/questions/515501/add-expires-header-conditionally-based-on-mime-type-in-nginx