How to be sure my static files are served by PA server and not by my flask application ?

Hello everyone,

I have an app running at , today after an update it took more than minute to load. Looking at the chrome dev console I found out that the banner image took more than minute to load. That makes me think maybe I got wrong the settings and the images are being served by my flask app like in my local environment. I did setup the static path in my PA console, but I am not sure if that really works. Any idea how to be certain of that ?

Many thanks

That's odd! The files that are loading slowly are and, right? They both take about 1.5 seconds to load on my machine, which isn't super-fast, but given that they're both about 500kB in size isn't too surprising. Is it consistently loading slowly for you? Where are you geographically? Might it just be a slow connection between our servers (on the US east coast) and your location?

Thank you for the reply,

I am located in Europe, and today the load is much better today about 3sec, it's ok for now! What about my original question, I am still not sure about how those images are served... maybe it could help if the PA static server could handle them with proper caching and so on.

Interesting. Did you reload your website from the "Web" tab after setting up the static file mapping? If not, that might explain the problem: when you add the mappings to the static file table, they don't take effect until the website is restarted, so it's possible that you added the mappings, but didn't reload -- which would mean that Flask would be handling the static files, which would be slow. Then, at a later point, the website was restarted, either because you did it yourself or due to some system load-balancing moving it to another server, at which point the static file mappings kicked in and things sped up.

In terms of caching -- we provide a last-modified header in the response when a browser requests a static file. Most browsers, when they request the file again, will send an "if-modified-since" header set to the last-modified value from the response to the previous request, which means that if the file hasn't been changed, we just send back a "not changed" message instead of the full file -- which should give you all the caching you need.

Yes I did the reload the website from the Web tab; and immediately after that the site was super slow. It looks like your assumption is correct: at some point the static file mappings kicked in and things sped up...

Which bring me again to the original question : How to be sure who is handling the static files ? Is it Flask or PA server.

Answering to that question will help me be more confident next time I deploy...

Hmm, that's an interesting question. I can't think of anything you could check that would make it completely certain. Here's an explanation of how it works, though, which hopefully should help you get a reasonable level of certainty.

When a request comes in, our system first looks at your static files table. Let's consider a request to It will look for a static file routing with the "URL" set to "/static/". If it finds one (which it will for your website as it's currently configured) then it will look at the "Directory" associated with that static file mapping. In your code, this would be something like /home/rlog/mysite/static/ (I've not put in exactly what it would be to avoid exposing any private information about your account). It would then look for the file /home/rlog/mysite/static/banner-logo.svg in your private file storage. If it's there, then it will serve it up -- otherwise it will pass the request on to Flask for processing.

So, if you step through that process manually and confirm that the file is in the expected place, you can be as sure as you can be that it will be served by the static files system.

Understood, I like the approach, makes sense to me!

That gives me actually an idea how to answer my question : you would have to setup 2 directories

  • /static/ -- put here static asset for the dev environment
  • /static-prod/ -- for prod env; the directory name is what will be mapped to the url "static" in prod

Provide different content on those folders -- e.g. a watermark in dev images. then here we you know who serve what.

Thank you @Gilles for your time spent on 10eur/mo customer like me. But hey, who knows when meets my expectation I will make sure to tell everyone how supportive you were in the early days ;)

Your idea sounds like it would work fine, though you'd have to be careful that you don't get unexpected behaviour differences between your dev and prod versions if there are different files in the 2 directories.