Adding Cache-control to a website (Apache)

Adding Cache-control to a website (Apache)

All CDN service have the ability to respect whichever cache control directives the origin server sends. 

Some even require the origin to provide caching headers, as they don't have the capability to set caching policy at the edge. 

Assuming your web application does not supply caching directives, the Apache web server has an easy way to set caching via the .htaccess file. 

The following examples are all lines to be included in the .htaccess file

Cache on the edge for 10 days, and on the browser for 2 hours
Header set Cache-Control "public, max-age=14400, s-maxage=8640000"

Do not cache
Header set Cache-Control "private, no-cache"