

Ask HN: Serving rendered html and static content vs. building APIs - zman0225

Just a quick newbie question. When I was learning flask&#x2F;django I was taught to use certain python packages to render the html first on the server and then serve it. As I learned more and more technologies on the front end, I realized that letting frameworks render and serve web pages is kind of inefficient (that&#x27;s why we have nginx and apache, right?) So is it wiser to just build APIs on the framework end and have the static content served separately or have everything come from the framework?
======
soundoflight
Like all questions, it really depends.

I would build out your project entirely first then look for possible
optimizations like this. You will need to see how often this content changes,
how often it is requested and the cost of regenerating it. In addition to
this, you will want to look at the added engineering costs of this.

If it's something that rarely changes, I usually just have a background job
generate it and serve it as static content, but only if it is accessed a lot.

