Nodejs Express framework caching

前端 未结 4 1277
悲&欢浪女
悲&欢浪女 2020-12-07 19:31

I am using Nodejs and Express Js. Also I add NowJS to the Express Js to do some real-time stuffs.

In the configuration file I have

app.configure(\'pr         


        
4条回答
  •  醉梦人生
    2020-12-07 19:38

    The following code does the trick :

    var cacheTime = 86400000*7;     // 7 days
    
    app.use(express.static(__dirname + '/public',{ maxAge: cacheTime }));
    

    However my public directory contains CSS as well as html files.

    Is there a way i can cache css files only and not html.

    I tried the setting "no-cache" in meta tag for html file but it didn't work.

提交回复
热议问题