Tracker.autorun and browser's cache clearing

Hi, I have small problem with getting sync sessionId on the client and on the server. Please, take a look at this snippet:

Tracker.autorun(function () => {
  const currentSession = Session.get("sessionId") ||"session");
  if (typeof currentSession !== "string") {
    const serverSession =;"session", serverSession);
    Session.set("sessionId", serverSession);
  if (currentSession && typeof Session.get("sessionId") !== "string") {
    Session.set("sessionId", currentSession);

Sessions = Meteor.subscribe("Sessions", Session.get("sessionId"));

Everything works almost good here, before I trying to clear browser’s cache. Keep in mind when we do it, page will not reload automatically at least in Chomium, Opera.

Ok, when I cleared cache, nothing happens on the client (as far as I can see), but publication on the server is called with old serverId. And server continue to work with old sessionId while browser doesn’t have sessionId at all because we cleaned the cache.

Of course, I could just reloading the page to get new sessionId, but not all users know about this :wink:

Tracker is hard to understand for me, so maybe I missed something here?

Why is subscribe not in the autorun ?

I can not say exactly why, but if it is putted in the Autorun, it does not have any effect on this problem.

Then I will ask one more question: is it possible to track changes inside"session")? Because, I failed to get the Tracker.autorun to track"session").

On a side note, that’s because you have to check if the subscription is ready in the autorun:

Tracker.autorun(computation => {
  let Sessions = Meteor.subscribe("Sessions", Session.get("sessionId"));
  if (Sessions.ready()) { // reactive!
    // now it's ready, put logic here...

I disagree. If user clears the browser’s cache Session.get("sessionId") will be out of date. So first I need to make update of Session.get("sessionId"), and then make new subscription. Am I wrong with that?

My latest version looks like so:

Tracker.autorun(function () {
  if (typeof"session") !== "string") {
    const newSession =;"session", newSession);
    Session.set("sessionId", newSession);
  if (typeof Session.get("sessionId") !== "string") {
  Subscriptions.Sessions = Meteor.subscribe("Sessions",

but this all worth nothing, because if I clear the cache recomputation won’t happen.

Currently I solved the problem by extending with additional typeof"session") !== "string" ckeck before calling accounts.callLoginMethod, but maybe where is more gentle way to track“ReactionCore.session”) changes?