Homepage index.ejs displays the user name and user avatar. Click the personal center to jump to the information details page; modify information and upload avatars on the information details page, click save and return to the homepage index.ejs from the information details page. After these operations, the database data has been updated, but the avatar in the homepage indexejs has not been updated. If you clear the browser cache and log in again, you can update the user avatar.
I would like to ask if this is a cache problem. Some of the writing methods I found do not work, so I will post them below
The first:
var ejs = require('ejs'),
LRU = require('lru-cache');
ejs.cache = LRU(100);
Second type:
app.use(express.static(path.join(__dirname, 'public')));
app.get("/*",function (req, res, next) {
res.setHeader('Last-Modified',(new Date()).toUTCString());
next();
})
Third type:
app.set('view cache', false);
Fourth type:
app.disable('view cache');
Even if I write all of these, it won’t work. I still need to clear the browser cache before I can update the user avatar. Please give me some advice.
習慣沉默2017-06-10 09:50:06
Would it be better to add version control to the avatar?
This way, the avatar that has not been changed can be cached
After changes, it can be refreshed in time