Hacker News new | ask | show | jobs
by jmstout 4385 days ago
Doesn't this method of including dynamic data in the index.html page prevent it being served from a CDN?

When serving a web application, I'm generally more worried about the time it takes before the user sees a response, even if the page isn't fully hydrated yet, than the total load time.

Requiring a hit to the database before the index.html is served seems like a bad idea to me, even if it is 'saving' a request to the API.

2 comments

> Doesn't this method of including dynamic data in the index.html page prevent it being served from a CDN?

if your cdn is serving static html pages then yeah probably. If it's just serving assets like images/js/css/fonts, it shouldn't be an issue since those would all be extra reqs anyway, and not "compiled" into the html.

I serve up all my angular view templates as static files (ui-router), use ng-include for dumb stuff like footer text that never changes, and rely on the API (hmac) for populating content.

Perhaps this is over opinionated, but angular seems to me to be designed so that you don't have to do ANY view templating bullshit on the server. I don't have a single angular app that hits the app server for an html template compiled by code. In fact the only thing I do serverside templating in now is drupal.

I agree. These days static templating is preferred over dynamic templating. The static files, like index.html and of course other resources like images and stylesheets are cached and served by a CDN very quickly. Dynamic content is fetched using a HTTP or a WebSocket api.

Dynamic templating is a pretty old-fashioned way to build websites. The practise originates from cgi and PHP.