Welcome! Log In Create A New Profile

Advanced

Re: cache all endpoints but one: nginx settings

October 10, 2016 03:34PM
Update about FLASK:

as you indicated in:

I am using errorhandler decorator, but returning a template in the handler function:

@application.errorhandler(404)
def error_404(e):
application.logger.error('Page Not Found: %s', (request.path))
#return render_template('404.html'), 404
return render_template("404.html", error = str(e))

In this situation, it is not clear to me if nginx will read a 200 response, for actually the template 404.html is found, or the 404 error, handled by the decorator.

Actually, with the suggestions from:
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_valid

I can see:
/api/_invalidpage
returned header: X-Proxy-Cache: MISS and it is not cached now.
while
/_invalidpage/ (the page a user will see for that specific page)
returned X-Proxy-Cache: HIT

I would like to cache the html template but not the 404 api response.
I think now is correct but would appreciate a clarification on how a template is handled inside handleerror in flask, to better understand how things works.
Subject Author Posted

cache all endpoints but one: nginx settings

Luigi Assom October 04, 2016 11:18AM

Re: cache all endpoints but one: nginx settings

Maxim Dounin October 04, 2016 12:30PM

Re: cache all endpoints but one: nginx settings

gg4u October 10, 2016 03:14PM

Re: cache all endpoints but one: nginx settings

gg4u October 10, 2016 03:34PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 270
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready