Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching issues #3180

Closed
aniinprni opened this issue Jan 23, 2017 · 6 comments
Closed

Caching issues #3180

aniinprni opened this issue Jan 23, 2017 · 6 comments
Assignees
Labels

Comments

@aniinprni
Copy link

Hi,
I am using expressjs in my nodejs application. We have internationalization(supporting multiple languages) in our application. For this internationalization to achieve i used i18next with mongodb backend. when ever i update translations i used to reload the translations. It is working fine in my local machine. But in Linux environment it is misbehaving. like first time page refresh it is giving me correct name,but from next refresh of same page onwards giving me old data. In browser console also updated data only printing. So i approached i18next team to look into it. After debugging, they told that it might be a some cache issue related to express js . So i am posting here my problem. Kindly suggest me. i have been stagnated by this issue since 10 days.
i am using expressjs 4.12.4 version.

Thanks in Advance.

@dougwilson
Copy link
Contributor

Hm, that is definitely weird. Have you tried the most recent express version to verify it is not a bug that has been fixed? If so, is it possible you can provide some code that demonstrates the issue so we can work together to resolve?

@aniinprni
Copy link
Author

Hi, i updated expressjs and tried. It is behaving same as before.
Here is the code. In my server.js

var i18n = require('i18next');
var Backend=require('i18next-node-mongodb-backend');
var middleware=require('i18next-express-middleware');
var express = require('express');
var app = express();
app.use(express.static(path.join(__dirname, 'public')));
i18n.use(Backend).use(middleware.LanguageDetector).init({
		debug: false,
		load: ['ar','en'],
		fallbackLng: 'ar',
		backend: { 
			uri: 'mongodb://localhost/test',
			collection: 'i18next'
		},
		detection:{
			  order: ['path','cookie'],
			  lookupFromPathIndex: 0,
			  lookupCookie: 'lng'
		}
	}, (err, t) => {
		return t;
});
app.use(middleware.handle(i18n, {}));

in my routes.js

app.post('/urlforlangupdate',function(req,res,next){
i18next.reloadResources(["ar","en"]);
   res.json();
});

here i need to reload translations dynamically with out server restart. i think it is related to express cache . i might be wrong also. Kindly suggest me to reload translations dynamically.

@dougwilson
Copy link
Contributor

I'm not sure what exactly is going on, but I don't see you using res.render anywhere, which is the only thing that involves any kind of cache in Express. Can you elaborate on what cache you're running into? Are those modules performing some kind of cache?

@aniinprni
Copy link
Author

i am using i18next module to load translations from mongodb. whenever a change is happened for translations i need to update those translations into my application(say main web application) with out server restart. here what i am doing is i will update translations from one application(say internal web application). When that update happens i am triggering one post request to reload those translations in my main application. Hope you understand what my requirement is. This requirement absolutely working fine in my windows local machine. but when i moved to linux, giving me problem. I printed those translations via console.log. it is printing updated data in both browser and node consoles. but when i refresh the browser url, still it is showing old translations. if I try to modify the same translation twice or trice then it is giving one time one translation and next time old translation. Like this it is happening. Hope you understand what is my problem. And sorry for my bad english. Kindly suggest me on this

@dougwilson
Copy link
Contributor

Hi @aniinprni I'm not sure I understand the issue, mainly because I'm not familiar with i18next module. Can you elaborate on what cache you're running into? Are those modules performing some kind of cache? The only caching in Express itself is really in res.render, but I don't see you having that anywhere in your code above.

@aniinprni
Copy link
Author

Ok thank you dougwilson

@dougwilson dougwilson self-assigned this Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants