Forums

Browser caching for static files doesn't work

Hey,

I have hosted a flask app and I want to cache my static files like css,js and img. So i specified "/static/" for URL, and "/home/AlloTH/alloth/app/" for PATH.

When I check to GTMetrix, my parameters don't seem to work :/.

I'm not entirely sure what you mean by your parameters don't work. Are your static files not being served? Not being served in some way that you think they should?

Hum...I misspoke.

When I ask a performance report from GTMetrix or Pingdom, I got a Grade F for "Leverage browser caching". They say that : "The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources" for all my static files.

When I work with PHP, I write a .htaccess in order to correct this point. But with pythonanywhere, it doesn't seem to work. I read somewhere the tip cited above, but maybe that's not what I need to do?

We use settings for user static files that are a good compromise for everyone. If a site checker is it's own specific opinion about what the right values are then we might disagree.

I trust you. I tried to respect a maximum of SEO rules, and I think that it's enough :). I agree with you, your settings are a good compromise even for me. Thank you for your quick reply !