lundi 30 mars 2015

Node/express caching

I'm developing an application that's meant to serve as a control panel for account and character management of a video game server.


I'm using Node/express for the interface as well as serving the static content. For example:



app.use( express.static( path.join(__dirname, 'public') ) );
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');


And an example of one of the resources



router.get('/characters/:name', function(request, response) {
if ( request.user ) {
new Database.Game.Character({char_name:request.params.name})
.fetch()
.then(function(character) {
var chara = character.toJSON();
response.render('character', {
username: request.user.get('login'),
character: chara
});
})
.otherwise(function(error) {
response.render('error');
});
} else {
response.redirect('/');
}
});


The application is working fine, however when it comes to the static content I'm having caching issues and I'm not sure how to go about figuring out just exactly where the problem lies. I've been uploading new images and modifying existing quite haphazardly on the server side, and they're not being displayed and result in 404's on the client side.


missing image


1.png will still be retreivable from the server even after I've cleared my cache, removed it from the server, and restarted my node application. Here is what I've tried so far



  1. I've cleared the cache on my browser before each test to no avail

  2. I've tested the website from multiple computers and multiple browsers and received the same results

  3. I've tried app.disable('etag') to no avail.

  4. I've tried adding Cache-Control to the response header to no avail

  5. I've tried adding {maxAge:1} to express.static to no avail

  6. I've tried searching if express has any cache options to come across npm clear cache which has also not helped.


Due to the circumstances of receiving the same results on multiple computers, I have the feeling that it has to be server side or I'm overlooking something very simple. Can anybody offer a bit of advice?


Aucun commentaire:

Enregistrer un commentaire