Documentation

This documentation and answers will help you get started and master the way you use PageCDN for better content delivery.

Configuring PageCDN

This guide will help you configure PageCDN repos for better performance and control.

HTTP Cache Control

PageCDN allows you to configure Cache-Control header:

  • on your origin server, or
  • in PageCDN's repo configuration panel.

To change how browsers cache the files delivered by PageCDN:

  • Goto 'My Websites' page and choose the CDN repo that you want to configure.
  • On the next (CDN Files) page, click 'Configure' to open configuration form.
  • Scroll down the configuration form a little and look for 'Browser Cache TTL' option.
  • There you can specify Expiry time (or Time to Live) of browser cache in Seconds, Minutes, upto Years.
  • To cache files forever in the browser, input -1 in the box.
  • To allow the origin server to specify cache control headers for each file, input 0 in the box.
  • Hit 'Save Changes'.

PageCDN allows you to specify TTL at repo level only. For a more fine grained control over caching of individual files, it is recommended to disable CDN overrides by specifying 0 in 'Browser Cache TTL' and set Cache-Control header at origin server.

Edge Cache Control

Edge Cache Control is handled a little differently than the HTTP Cache Control in that PageCDN does not allow you to specify Edge Cache Control headers at Origin server. To change how longer PageCDN maintains copies of your files at its servers:

  1. Goto 'My Websites' page and choose the CDN repo that you want to configure.
  2. On the next (CDN Files) page, click 'Configure' to open configuration form.
  3. Scroll down the configuration form a little and look for 'Edge Cache TTL' option.
  4. There you can specify Expiry time (or Time to Live) of CDN cache in Seconds, Minutes, upto Years.
  5. To cache files forever on the CDN, input -1 in the box.
  6. Hit 'Save Changes'.

Compression

PageCDN pre-compresses the following file types before delivery, and caches the compressed file for future use to save on resource requirements of high compression quality.

The file formats compressed are: js, css, map, svg, ttf, json, template, sass, scss, less, txt, xml, html, htm, rss, coffee, ts and sql. Most of these formats are rarely used in production. Some of these file types like .sql are usually database dumps that can save download time if compressed.

PageCDN uses 3 levels of compression: 'Moderate', 'High' and 'Extreme' that correspond to the brotli compression quality level of '5', '9' and '11'. If a browser accepts gzip compression only, PageCDN compresses the response using gzip quality '5' only. However, we have observed that only less than 10% of requests for compressible resources require the use of gzip.

If a file is smaller than 500 bytes, it is not compressed at all as compressing such files are not expected to gain measureable results. Not compressing such files is unlikely to make your site load slow in real world use cases.

Choosing the optimal compression quality

While brotli-11 compression quality ('Extreme' compression in repo configuration) generates the best possible results, it is not always recommended. 'Extreme' compression is extremely slow for the first run on every file and can significantly slow down your page loads if even a single file has changed on that page. So, if the files change too often (during live development), or if your website uses too many compressible files, you are recommended to lower down the compression quality to 'Moderate' in repo configuration panel. You can reset the repo to use 'Extreme' compression when these conditions are no longer true.

HTTP/2 Server Push

Server push lets PageCDN preemptively “push” files to the browser without the user having explicitly asked for them. When used with care, you can send what you know the user is going to need for the page they’re requesting.

For HTTP/2 Server Push to work, you have to specify a file that pushes additional files. So, you have to:

  • Goto 'My Websites' page and choose the CDN repo that you want to configure.
  • On the next (CDN Files) page, click 'Configure' to open configuration form.
  • Scroll down the configuration form and look for 'Server Push' option. You have to specify relative path of the file that you want to push additional files with.
  • In the next box, specify relative paths of files that you want be pushed with the previous file.
  • Hit 'Save Changes'.

You can specify only one HTTP/2 Server Push event per repo. For multiple Push events, you need to use multiple repos on the same website to make this configuration to work.

The file paths must be repo relative. So, if you want to trigger push event on http://example.com/static/styles.css where http://example.com is the origin, the file path should be static/styles.css. The same applies to the files that are being pushed.

Server Push is a feature that needs to be used with care. If you push unnecessary files, you are going to put extra load on browser that may limit available network bandwidth required for other necessary resources.