Content served by a webserver can be broadly broken into two categories, static, and dynamic.
Static content is delivered to the end user without being generated or processed. The content is stored on the webserver in the form of a file and that same file is delivered to every user. Traditionally a CDN would only store and serve the static content of a website.
Conversely, dynamic content is generated by the server for every request, often involving several database queries and considerable code execution. The content served may vary depending on several factors, such as the user's behaviour and location. Examples of this could be a slightly different page being presented whether a user is logged into a website or not, has added items to their shopping cart, selected options on the website, or has engaged with some marketing.
Caching Dynamic Content
Most modern websites are built with Content Management Systems (CMS) like Wordpress, Shopify ,Magento, or Drupal. CMS systems generate pages for every request, making them 'dynamic', but without necessarily changing the content, or only very rarely changing.
Similarly, API calls might return the same information if the same input is supplied. This creates an opportunity to cache this content saving the server from generating the content for every request.
To cache dynamic content a request is made that generates the requested output, be it an HTML page, image, JSON, etc. The output is then stored as a static file, or kept in memory, this static response is then served for every request until it either expires or is purged. Upon expiry, or a purge event, the server is asked to regenerate the content which is then again stored as a static file. Caching dynamic content can dramatically improve load times and cut server utilisation.
Caching can happen on the same server as the main server, as is the cache for many optimising Wordpress plugins, or distributed globally on a CDN, as is the case with Peakhour.