You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Jack Bates <6n...@nottheoilrig.com> on 2012/05/06 21:24:03 UTC
Header parameters and check URL exists in cache?
Hi, do you know of any examples of parsing parameters in header field
values that you can suggest to me? e.g. matching charset=UTF-8 in
"Content-Type: ...; charset=UTF-8" or rel=duplicate in "Link: <...>;
rel=duplicate"
Also can you suggest any examples of checking if a given URL already
exists in the cache or not?
I am attempting a plugin [1] to take advantage of Metalink [2] to
redirect clients to mirrors that already exist in the cache. I am trying
to loop over RFC 6249 "Link: <...>; rel=duplicate" headers and check if
the URL already exists in the cache
[1] https://github.com/jablko/dedup
[2] http://metalinker.org/
Re: Header parameters and check URL exists in cache?
Posted by Leif Hedstrom <zw...@apache.org>.
On 5/6/12 1:24 PM, Jack Bates wrote:
> Hi, do you know of any examples of parsing parameters in header field
> values that you can suggest to me? e.g. matching charset=UTF-8 in
> "Content-Type: ...; charset=UTF-8" or rel=duplicate in "Link: <...>;
> rel=duplicate"
No, there's not such parsing provided in the API.
>
> Also can you suggest any examples of checking if a given URL already
> exists in the cache or not?
Technically, I *think* TSCcacheRead() can be used to check for the existence
of an object in the HTTP cache, and perhaps even read the header for what is
in cache. The caveat is that these APIs were not intended to work on the
HTTP cache, but for your case, it might work. Only one way to find out.
Fwiw, the APIs TSCacheWrite(), TSCacheRead() etc. were intended for someone
to store and retrieve non-HTTP cache objects. The core obviously uses the
same underlying code for the HTTP cache, the complication is that it uses it
in a way that is not exposed via current APIs (such that you could not get
to the body of an HTTP object via these objects). There's an example
protocol plugin that uses these APIs for storing content in the cache.
Cheers,
-- Leif