Home  >  Q&A  >  body text

Nginx, as a development environment server, cannot clear the static file cache

debian 6 nginx 0.7.67 (apt installation) is used as a development environment. It is found that after modifying static files (js, css, html), it cannot be updated in time, and proxy_cache is not configured
It doesn’t seem to be a problem with expires. It doesn’t work even if you change the browser (the curl command retrieves all cached files). It’s nginx that sends cached files

大家讲道理大家讲道理2712 days ago512

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 17:31:18

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires      30d;
    }
    
    location ~ .*\.(js|css)?$ {
        expires      12h;
    }

    This is the configuration code for js and css cache time in nginx. You can set it very small and it should be fine

    You can refer to this http://www.ibm.com/developerworks/cn/...

    reply
    0
  • Cancelreply