trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

The regex_invalidate API doesn't work when I added cache rules in cache.config

Open VanillaHeaven opened this issue 4 years ago • 1 comments

Hello. I tried to use the regex_invalidate API in cache inspector utility to set a document invalid, but it seems doesn't work when I added the cache rule in cache.config.

Is the priority of the cache rule in cache.config the highest? How can I make the regex_invalidate API take effect while I configure the caching rules in cache.config.

The ATS version is 9.0.0, and the operating system I use is centos. The following is my test process:

I added cache rules in cache.config as follows:

dest_domain=test.source.com   scheme=http  revalidate=2d

The default expiration time is two days for the documents whose host name is test.source.com.

I initiated a request and got the response:

curl "http://test.source.com/1M/2" -x 127.0.0.1:8089 -vo /dev/null
...
< HTTP/1.1 200 OK
< Server: ATS/9.0.0
< Date: Tue, 29 Jun 2021 10:26:49 GMT
< Content-Type: application/octet-stream
< Content-Length: 1048576
< Last-Modified: Fri, 16 Apr 2021 13:11:12 GMT
< ETag: "60798cf0-100000"
< Accept-Ranges: bytes
< Age: 0
< Proxy-Connection: keep-alive

And I get the hit status which is hit-fresh from the log and the response header X-Cache.

curl "http://test.source.com/1M/2" -x 127.0.0.1:8089 -vo /dev/null -H "X-Debug: X-Cache"
...
< HTTP/1.1 200 OK
< Server: ATS/9.0.0
< Date: Tue, 29 Jun 2021 10:53:39 GMT
< Content-Type: application/octet-stream
< Content-Length: 1048576
< Last-Modified: Fri, 16 Apr 2021 13:11:12 GMT
< ETag: "60798cf0-100000"
< Accept-Ranges: bytes
< Age: 4
< Proxy-Connection: keep-alive
< X-Cache: hit-fresh
<
{ [data not shown]
100 1024k  100 1024k    0     0   169M      0 --:--:-- --:--:-- --:--:--  200M

According to the official documentation, I tried to use the regex_invalidate API in cache inspector utility to set the document invalid, and the result of the web page response shows that the operation has been successful. image But when I made the request again, the response result shows that the cache is still hit.

curl "http://test.source.com/1M/2" -x 127.0.0.1:8089 -vo /dev/null -H "X-Debug: X-Cache"
< HTTP/1.1 200 OK
< Server: ATS/9.0.0
< Date: Tue, 29 Jun 2021 10:26:49 GMT
< Content-Type: application/octet-stream
< Content-Length: 1048576
< Last-Modified: Fri, 16 Apr 2021 13:11:12 GMT
< ETag: "60798cf0-100000"
< Accept-Ranges: bytes
< Age: 172
< Proxy-Connection: keep-alive
< X-Cache: hit-fresh
<
{ [data not shown]
100 1024k  100 1024k    0     0   138M      0 --:--:-- --:--:-- --:--:--  166M

I checked the debug log, and it showed that the expiration time of the document is based on the caching rules configured in cache.config, so that the regex_invalidate API doesn't work.

[Jun 29 18:29:41.104] [ET_NET 23] DEBUG: <HttpTransactHeaders.cc:438 (calculate_document_age)> (http_age) [calculate_document_age] age_value:              0
...
[Jun 29 18:29:41.104] [ET_NET 23] DEBUG: <HttpTransact.cc:7514 (what_is_document_freshness)> (http_seq) [10] document_freshness --- current_age = 172
[Jun 29 18:29:41.104] [ET_NET 23] DEBUG: <HttpTransact.cc:7515 (what_is_document_freshness)> (http_seq) [10] document_freshness --- age_limit   = 172800
[Jun 29 18:29:41.104] [ET_NET 23] DEBUG: <HttpTransact.cc:7516 (what_is_document_freshness)> (http_seq) [10] document_freshness --- fresh_limit = 86400
[Jun 29 18:29:41.104] [ET_NET 23] DEBUG: <HttpTransact.cc:7535 (what_is_document_freshness)> (http_match) [10] [..._document_freshness] document is fresh; returning FRESHNESS_FRESH
[Jun 29 18:29:41.104] [ET_NET 23] DEBUG: <HttpTransact.cc:2557 (HandleCacheOpenReadHitFreshness)> (http_seq) [10] [HttpTransact::HandleCacheOpenReadHitFreshness] Fresh copy
[Jun 29 18:29:41.104] [ET_NET 23] DEBUG: <HttpTransact.cc:2653 (need_to_revalidate)> (http_seq) [10] [HttpTransact::HandleCacheOpenReadHit] Authentication not needed

VanillaHeaven avatar Jun 29 '21 11:06 VanillaHeaven

This issue has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community.

github-actions[bot] avatar Jul 20 '22 02:07 github-actions[bot]