'Nginx not caching Json files

I have a website which has a few graphs and charts which are of different types such as css, js and json types. I have setup nginx caching but the caching is not working for json types of files i.e. it isn't storing the json files to disk. I have added my configuration below:-

proxy_cache_path /mnt/logs/nginx/cache keys_zone=new_cache:10m max_size=1g use_temp_path=off;

    # For External routing
    server {
        listen       8102;
        server_name  example.xyz;
        
        set $rw_rule 1;

        if ($host = 'demo.example.xyz') {
           set $rw_rule 0;
        }
        if ($rw_rule = 1) {
            return 404;
        }


        proxy_buffering on;
        proxy_buffers 8 32k;
        proxy_buffer_size 64k;


        proxy_cache new_cache;
        proxy_cache_key $scheme$proxy_host$request_uri;
        proxy_cache_methods GET HEAD;
        proxy_cache_valid 202 1d;
        proxy_ignore_headers Cache-Control Vary X-Accel-Expires Expires;
        
        add_header X-Cache-Status $upstream_cache_status;

Can someone please provide some insight into it? Thank you! :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source