When using a template engine (pug, thymeleaf, etc...), the server renders an html file dynamically and then delivers it to the client upon each page request.
Suppose there is a company proxy server or a cache server between the server and the client.
will there ever be a cache hit? don't we lose all the benefits of internet cache when sending new versions of our html to clients all the time?
If the URL is the same for all users then yes, the CDN will be hit most of the time. You will need to do something like cache-control or set up the CDN to bypass the cache when a certain path is hit.
This is why a lot of sites use AJAX calls to fill the pages post-load. All of the HTML can be cached in the CDN and the CDN is configured to bypass cache for all /api
paths.
Our site uses CDN for the public pages (which are still generated with pug), then when you sign in the CDN is instructed to never cache the "personal" pages that are rendered dynamically.