sablierapp / sablier

Start your containers on demand, shut them down automatically when there's no activity. Docker, Docker Swarm Mode and Kubernetes compatible.
https://sablierapp.dev/
GNU Affero General Public License v3.0
1.46k stars 48 forks source link

Cloudflare and cached loading page resulting in javascript/mime errors #388

Open valankar opened 2 months ago

valankar commented 2 months ago

Describe the bug I'm running Sablier via Caddy behind a Cloudflare tunnel. My app is a FastAPI/NiceGUI Python app, which retrieves .js files. It generally works well most of the time, but sometimes I get a bunch of errors with the .js files actually returning the Sablier loading page HTML. It looks like the following:

js errors

When I go to inspect those .js files in the browser, it appears the text is actually the Sablier loading page:

js errors 2

    <h1><span>Starting </span> <span class="error_code"></span>...</h1>
    <p class="output"><span>Your instance(s) will stop after 6 hours of inactivity</span>.</p>
...

What I think is happening is Cloudflare is caching that loading page and returning it for all requests, even after the container is up. I notice the page doesn't have any headers to affect caching. Shouldn't it have some to instruct clients not cache it?

Context

Expected behavior Maybe the Sablier loading page should specifically have no cache headers.

acouvreur commented 2 months ago

Hello @valankar that's actually a pretty good point!

Do you think you could submit such fix ?

valankar commented 2 months ago

Sure I'll do some tests with https://github.com/acouvreur/sablier/blob/main/docs/themes.md first.

acouvreur commented 2 months ago

@valankar any feedback on the released version ? Does it work as expected ?

valankar commented 2 months ago

It still unfortunately happens around 5% of the time, usually when I hit my website on my phone (Safari). It's rather difficult to debug. I know that NiceGUI/FastAPI use websockets, so perhaps using dynamic strategy is not the right thing. Everything works fine with blocking strategy.