Serverside Astro JS global variable

I have a project on Serverside rendered Astro JS. I ‘m try pass variable between .astro files on runtime.

For this I use {...}.ts import/exports to share variable between files.

a.ts

export const data = {
   myVariable: false
}

x.astro

---
import { data } from "../a";

if(data.myVariable === true)
  Astro.rewrite("/404/");
---

<SomeComponents />

y.astro

---
import { data } from "../a";
...
...
if(anyVar.length < 1) data.myVariable = true;

In this case, first run the system works fine. But in later requests, AstroJS was cache data.myVariable to true. It always response 404.

How can I share variables in memory and not cacheable?