4

We're planning an integration with a CDN (likely Akamai) and are trying to determine how low we could go for a max-age value.

For a site that could get a few hundred thousand folks hitting the site after a tweet goes out, having content be cached will help reduce the burden on the servers. Having said that, our client is sensitive to not being able to quickly modify content if something were to get published prematurely.

Our plan has been to implemented a phased cached-control process where we start out for the first 1-10 minutes at a low (20-30 seconds?) Cache-Control max-age and then as things appear to be in working order, we'll begin to increase the max-age as content has been live for a period of time. For example, after a few hours, we might start to set that at 60 minutes... and after a day, we might throttle that to a day.

Circling back to the original question, is it possible to set a cache-control header at a low level like 20-30 seconds? (Does Akamai set a min value here? I haven't been able to track down any specifics here on my Google searches)

  • I recommend you ask Akamai. This likely varies with the level of service you use. Also, instead of breaking caching, you may want to consider versioning your static assets. You can then use micro-caching or ESI in Varnish for your HTML. – jeffatrackaid Aug 12 '14 at 20:39
1

I have not used them for a long time, but if you are talking about the cache control header they set when serving content from their CDN, it gets pulled from your source. So for example if you have a pull with the cache control header of max-age 10s then the CDN will copy that. (same goes for cloudfront). The only CDN i am aware of which lets you override these headers via interface is MaxCDN.

As for CDN, typically you set caching as long as possible. What point is a CDN (other than an expensive way to geo-locate your site) if the cache control headers are set so shortly. When you have brief headers, the cdn needs to reach out to your site to pull fresh content, this can add a delay to your visitor actually grabbing the content themselves and is known as a cache miss.

Your best bet if you plan to phase in CDN is just to use it for Static Resources such as Images, Icons, CSS and Javascripts. If you create your CSS, Images, Or JS serverSide then you need to look into a way to purge these resources, or better version them with either a querystring or url parameter.

Again. Akami was soooo expensive compared to other options, you really only benefit for long cache headers (1 year or so)

  • 1
    One can override origin caching headers in Akamai nowadays. – Tero Kilkanen Aug 13 '14 at 0:43
  • Great, thanks for the update. Seems like Cloudfront is a bit behind the times for cache headers. Almost as bad as Azure CDN which still suffers from lack of origin pull. – Frank Aug 13 '14 at 3:05
1

Akamai has no minimum Cache TTL value. You can set 1 second or 0. However what you are trying to is better achieved with origin cache control headers because changing settings on Akamai isn't instant due to the size of the network.

I would recommend you start with atleast 5 minutes to begin with although I find 10 minutes is the most ideal lowest.

Now for modifying content I suggest using the following combination on your cached content with Akamai.

  • set a Last Modified Header on your content
  • On Akamai set IMS check or TTL of 30 seconds to 1 minute.
  • When content is modified set the new datetime by code correctly. Ensure your system clock is set correctly on the origin side. Ensure the format of LMS header is correct.

With the above you will be serving only 304 no body content if nothing changes

  • Alternatively use "Etag" and ask for "Etag" to be enabled on you Akamai configuration.
  • everytime content is modified update the eTag. Etags are not automatically enabled on Akamai

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.