You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@trafficserver.apache.org by Tim Traver <tt...@simplenet.com> on 2014/01/30 01:25:14 UTC
examples of caching only certain objects
Hi all,
So, I'm trying to set up some rules in my reverse proxy to not cache
certain objects, as they get changed frequently enough by the users as
to annoy them, and I don't have an easy method for them to clear caches
for particular objects just yet.
So, in my cache.config file I have a rule like this :
dest_domain=domain.com suffix=css action=never-cache
If I understand that correctly, that should tell ATS to never cache
files that end in .css
But when I have that in place, I still see the initial hit going to the
origin server, and then subsequent requests getting served by ATS with
the cH flag meaning that it got it from its cache.
I know there are more moving parts as to other config settings that
might be clobbering this one, but is that basically the correct way to
have ATS ignore certain file types?
I essentially want to make this reverse proxy only cache image files,
which are truly static for now.
Thanks,
Tim
Re: examples of caching only certain objects
Posted by Reindl Harald <h....@thelounge.net>.
Am 30.01.2014 20:58, schrieb Tim Traver:
> On 1/30/14, 12:14 AM, Reindl Harald wrote:
>> just look in your origins access log - i bet the requests after the first are answered with status 304 which
>> means "Not modified" because httpd send an ETAG and ATS sends If-Not-Modified headers, so the origin is contacted
>> but get the checksum of the reverse-proxy and aswers "no change" however, i would *not* solve that on the
>> reverse-proxy just configure the origin to send teh correct expires headers even in case the CSS is changed all
>> day long is 2 seconds caching fine and if you ever get a high load on that site it makes a difference if ATS asks
>> every request for a new version or for 2 seconds not contacts the origin at all <IfModule mod_expires.c>
>> ExpiresActive On ExpiresByType text/css A2 ExpiresByType image/jpeg A60 ExpiresByType image/jpg A60 ExpiresByType
>> image/gif A60 ExpiresByType image/png A60 ExpiresByType text/html A60 ExpiresByType text/javascript A60
>> ExpiresByType text/comma-separated-values A60 ExpiresByType text/tab-separated-values A60 ExpiresByType
>> application/javascript A60 ExpiresByType application/x-javascript A60 ExpiresByType application/xhtml+xml A60
>> ExpiresByType application/xml A60 </IfModule>
> Thank you Reindl.
>
> I think that you are correct in that the proper way to control which objects are cached and for how long is to
> control it on the apache side with the Expires header. That way, there is no additional configuration in ATS
yes, more important: ATS respects no-cache headers and <IfModule mod_expires.c>
works on <Directory>, <Location>, <VirtualHost> base too, so you can control it
very fine while ATS does not need to know anything about domains/folders/locations
i try to avoid any complexity on ATS because the httpd-configs are complex
enough for some hundret domains with all sorts of exceptions depending on
the application and the only thing i want to maintain on ATS is for which
domains it accepts connections (remap.config) and the dnsmasq-hosts-file
to make such nice things possible:
map http://domain1.example.com http://domain1.example.com
map http://domain2.example.com http://domain2.example.com
that makes no sense at the first view, but in my environment
"remap.config" is generated by a script calling our hosting
database and the same script generates "/etc/hosts.dnsmasq"
so ATS feels responsible for any domain hosted here and just works
the decision go to ATS or directly to the origin is made on the
public DNS, most sites do not need ATS because not enough traffic
my general intention for using ATS is in case of large-traffic-sites
have static files (images, css, javascript) "outsourced" and as much
as possible worker processes free for the php-sripts given that a
typical CMS request triggers a lot of static files requested
this way i avoid a multi-threaded MPM which would need a lot of
config changes in the complete infrastructure while prefork works
fine with a grown configuration
Re: examples of caching only certain objects
Posted by Tim Traver <tt...@simplenet.com>.
On 1/30/14, 12:14 AM, Reindl Harald wrote:
> just look in your origins access log - i bet the requests after the
> first are answered with status 304 which means "Not modified" because
> httpd send an ETAG and ATS sends If-Not-Modified headers, so the
> origin is contacted but get the checksum of the reverse-proxy and
> aswers "no change" however, i would *not* solve that on the
> reverse-proxy just configure the origin to send teh correct expires
> headers even in case the CSS is changed all day long is 2 seconds
> caching fine and if you ever get a high load on that site it makes a
> difference if ATS asks every request for a new version or for 2
> seconds not contacts the origin at all <IfModule mod_expires.c>
> ExpiresActive On ExpiresByType text/css A2 ExpiresByType image/jpeg
> A60 ExpiresByType image/jpg A60 ExpiresByType image/gif A60
> ExpiresByType image/png A60 ExpiresByType text/html A60 ExpiresByType
> text/javascript A60 ExpiresByType text/comma-separated-values A60
> ExpiresByType text/tab-separated-values A60 ExpiresByType
> application/javascript A60 ExpiresByType application/x-javascript A60
> ExpiresByType application/xhtml+xml A60 ExpiresByType application/xml
> A60 </IfModule>
Thank you Reindl.
I think that you are correct in that the proper way to control which
objects are cached and for how long is to control it on the apache side
with the Expires header. That way, there is no additional configuration
in ATS.
Tim
Re: examples of caching only certain objects
Posted by Reindl Harald <h....@thelounge.net>.
Am 30.01.2014 01:25, schrieb Tim Traver:
> So, I'm trying to set up some rules in my reverse proxy to not cache certain objects, as they get changed
> frequently enough by the users as to annoy them, and I don't have an easy method for them to clear caches for
> particular objects just yet.
>
> So, in my cache.config file I have a rule like this :
>
> dest_domain=domain.com suffix=css action=never-cache
>
>
> If I understand that correctly, that should tell ATS to never cache files that end in .css
>
> But when I have that in place, I still see the initial hit going to the origin server, and then subsequent requests
> getting served by ATS with the cH flag meaning that it got it from its cache.
>
> I know there are more moving parts as to other config settings that might be clobbering this one, but is that
> basically the correct way to have ATS ignore certain file types?
>
> I essentially want to make this reverse proxy only cache image files, which are truly static for now
just look in your origins access log - i bet the requests after the first
are answered with status 304 which means "Not modified" because httpd
send an ETAG and ATS sends If-Not-Modified headers, so the origin is
contacted but get the checksum of the reverse-proxy and aswers "no change"
however, i would *not* solve that on the reverse-proxy
just configure the origin to send teh correct expires headers
even in case the CSS is changed all day long is 2 seconds caching fine
and if you ever get a high load on that site it makes a difference if
ATS asks every request for a new version or for 2 seconds not contacts
the origin at all
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css A2
ExpiresByType image/jpeg A60
ExpiresByType image/jpg A60
ExpiresByType image/gif A60
ExpiresByType image/png A60
ExpiresByType text/html A60
ExpiresByType text/javascript A60
ExpiresByType text/comma-separated-values A60
ExpiresByType text/tab-separated-values A60
ExpiresByType application/javascript A60
ExpiresByType application/x-javascript A60
ExpiresByType application/xhtml+xml A60
ExpiresByType application/xml A60
</IfModule>