jvgutierrez commented on issue #9131:
URL: https://github.com/apache/trafficserver/issues/9131#issuecomment-1273092832

   > The question is "Is there a way to avoid cache if there's a certain cookie 
present?"
   
   Yes. Current documentation 
[states](https://docs.trafficserver.apache.org/admin-guide/files/records.config.en.html#proxy-config-http-cache-http)
 that `proxy.config.http.cache.http` is overridable. This means that it can be 
changed on a per-request basis.
   It could be done using a lua script with:
   ```
   ts.http.config_int_set(TS_LUA_CONFIG_HTTP_CACHE_HTTP, 0)
   ```
    ATS exposes the Cookies in lua via `ts.client_request.header['Cookies']`
   
   It could be also done leveraging the header rewrite plugin. The [COOKIE 
condition](https://docs.trafficserver.apache.org/admin-guide/plugins/header_rewrite.en.html#cookie)
 could be used to detect the cookie and [the set-config 
operator](https://docs.trafficserver.apache.org/admin-guide/plugins/header_rewrite.en.html#set-config)
 could be used to set `proxy.config.http.cache.http`to `0` effectively 
disabling caching for that request.
   
   > The other question is, to cache a document in different languages I saw 
that I can use the [Cache key manipulation 
plugin](https://docs.trafficserver.apache.org/admin-guide/plugins/cachekey.en.html)
 so I can assign a value from a cookie to the cache key and then show cached 
documents with the correct language to our users.
   
   Usually this is achieved with the `Vary: Accept-Language` HTTP header, you 
have more information on 
https://docs.trafficserver.apache.org/admin-guide/configuration/cache-basics.en.html?highlight=vary%20http%20header#caching-http-alternates.
 But you should apply some heavy normalization to the Accept-Language header to 
avoid cache fragmentation issues.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to