Вопрос

I am attempting to use akamai in my production app to cache basically every page when you are logged out, as only a small percentage of our users have accounts. However I want to be able to serve logged in users a none cached version of the page.

It seems that I may be able to do this in the controller with something like:

headers['Edge-control'] = "no-cache, no-store"

Will this work? Is there a better way to handle this, perhaps from a lower level, like Rack? I am having a lot of trouble finding standard practices.

Thanks!

Это было полезно?

Решение 2

This doesn't work because Akamai doesn't look at response header. You can use cookies to do it though.

Другие советы

I just dealt with this situation with akamai and wordpress. Even if akamai honors headers, it's probably more robust to base the rule on a cookie, the same cookie you use to track the login. That way, caching is tied to something visible -- if the cookie is not present, the user is not logged in. The header-based solution will be more prone to silent failures and would require more effort to validate for correct behavior.

Yes, you can in fact do this with headers.

Just send Edge-Control: no-store

Akamai does in fact examine response headers...how else could they honor cache-control headers from origin...which is a very common configuration setting.

As user3995360 states, you're better off using cookies to tell Akamai not to cache the results for a number of reasons:

  1. If Akamai has a cached version of your page, the logged in user will be served that - your server won't have a chance to send a different header.
  2. There's nothing to tell Akamai why the header is different for some requests - if your logged in user managed to get the no-store header, and then an anonymous user caches the page, you're back to point 1.

That being said, when I've done this in past we've had to involve the Akamai Consultants to enable this feature on our setup.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top