stewartpark / Flask-JSGlue

Flask-JSGlue helps hook up your Flask application nicely with the front end.
80 stars 40 forks source link

Optional caching? #14

Open imaia opened 7 years ago

imaia commented 7 years ago

An optional integration with flask-cache could do some wonders here.

stewartpark commented 7 years ago

Can you explain a little bit more about this? 😁

imaia commented 7 years ago

Yeap; if the js file is served by the view, it would be nice to have that response cached. With SPA's, caching this particular view is not a big problem, but with non-spa websites, it could quite help avoid unnecessary requests to the view.

Something like:

FLASK_GSGLUE_USE_CACHE = True

Then jsglue could lookup if flask-cache is installed and use it if available.

Another option would be to cache the view response with the http server cache. I'm unsure about which solution would fit best. Maybe having both options would be nice.

imaia commented 7 years ago

Another approach would be to create an option to disable adding gluejs route. This way, the user could add a route to gluejs with caching enabled.

pbrackin commented 7 years ago

@imaia is right on the money. I have a site that is an RPA "reduced page application", but still has some page loads... I chose to abandon JSGlue because of this. Also the nginx req limiter had to be raised just a tad to accomodate this JS or else it would get queued. If there was a way to cache the spun JS, I woulda liked to keep it. Its still a good idea.. just needs some tuning methinks. Good luck!