[PATCH configure] BZ 794755 - Static assets don't set Cache-Control headers https://bugzilla.redhat.com/show_bug.cgi?id=794755

Matt Wagner matt.wagner at redhat.com
Wed Feb 22 14:46:49 UTC 2012


On Tue, Feb 21, 2012 at 04:19:15PM -0500, John Eckersberg wrote:
> Use mod_expires to set expiration for css/js/png to one year.
> 
> From the BZ:
> 
> AssetTagHelper appends timestamps as a query parameter, so we can set a
> Cache-Control directive allowing these assets to be cached forever -- if we
> change a stylesheet, it will end up with a new timestamp in the URL and get
> reloaded automatically.
> ---
>  recipes/aeolus/files/aggregator-httpd-ssl.conf |    5 +++++
>  recipes/aeolus/files/aggregator-httpd.conf     |    5 +++++
>  2 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/recipes/aeolus/files/aggregator-httpd-ssl.conf b/recipes/aeolus/files/aggregator-httpd-ssl.conf
> index fce2f0d..9ace5de 100644
> --- a/recipes/aeolus/files/aggregator-httpd-ssl.conf
> +++ b/recipes/aeolus/files/aggregator-httpd-ssl.conf
> @@ -24,6 +24,11 @@ Alias /fonts "/usr/share/aeolus-conductor/public/fonts"
>  
>  RewriteRule ^/conductor/images/(.*).(png|jpg|gif|svg)$ /conductor/graphics/$1.$2 [R]
>  
> +ExpiresActive on
> +ExpiresByType text/css "access plus 1 year"
> +ExpiresByType text/javascript "access plus 1 year"
> +ExpiresByType image/png "access plus 1 year"
> +
>  ProxyPass /conductor/graphics !
>  ProxyPass /conductor/stylesheets !
>  ProxyPass /conductor/errors !
> diff --git a/recipes/aeolus/files/aggregator-httpd.conf b/recipes/aeolus/files/aggregator-httpd.conf
> index 567d648..8a0331e 100644
> --- a/recipes/aeolus/files/aggregator-httpd.conf
> +++ b/recipes/aeolus/files/aggregator-httpd.conf
> @@ -19,6 +19,11 @@ Alias /fonts "/usr/share/aeolus-conductor/public/fonts"
>  
>  RewriteRule ^/conductor/images/(.*).(png|jpg|gif|svg)$ /conductor/graphics/$1.$2 [R]
>  
> +ExpiresActive on
> +ExpiresByType text/css "access plus 1 year"
> +ExpiresByType text/javascript "access plus 1 year"
> +ExpiresByType image/png "access plus 1 year"
> +
>  ProxyPass /conductor/graphics !
>  ProxyPass /conductor/stylesheets !
>  ProxyPass /conductor/errors !
> -- 
> 1.7.7.6

First, you are my hero for sending this patch! ;) It was driving me
crazy.

However, it looks like it's not matching JS. They seem to have a MIME
type of application/javascript instead of text/javascript, so we're
still doing a conditional GET on every page load. I changed it locally
and now everything looks nice and clean -- I get the actual dynamic
page, and everything else is served via cache. So conditional ACK if you
can change "text/javascript" to "application/javascript" in both files.

Thanks!

-- Matt



More information about the aeolus-devel mailing list