Forum

HTTP caching

Fred
7 February 2017, 12:24
Hi Hugo,

I am trying to adapt theHTTP caching in Hiawatha post on the http://dotbalm.org website to newer directory setup..
I understand that this old syntax:
UrlToolkit {
ToolkitID = cache-control
Match ^/.*\.(css|eot|gif|htm|html|ico|jpeg|jpg|js|otf|pdf|png|ps|psd|svg|swf|ttf|txt|woff|woff2)(/|$) Expire 2 weeks
}

is now:
Directory {
DirectoryID = cache-control-2w
Path = /
Extensions = css, eot, gif, htm, html, ico, jpeg, jpg, js, otf, pdf, png, ps, psd, svg, swf, ttf, txt, woff, woff2
ExpirePeriod 2 weeks
}

Where is strugling is how do I convert this one?
UrlToolkit {
ToolkitID = cache-busting-control
Match ^/.*\.(css|eot|gif|htm|html|ico|jpeg|jpg|js|otf|pdf|png|ps|psd|svg|swf|ttf|txt|woff|woff2)(\?v=.*|\?ver=.*)?(/|$) Expire 1 months
}


could you please help?

Thank you
Joe Schmoe
7 February 2017, 14:55
Hi Fred,

I use Drupal which will append a query string with a version id to static assets (images, javascript, css) which is the same thing cache-busting-control toolkit is trying to workaround.

It appears that Hiawatha is smart enough to ignore the version string so the code should be almost exactly the same. I have a similar setup and it returns the correct expiration headers whether or not the version string is attached.

Directory {
DirectoryID = cache-busting-control
Path = /
Extensions = css, eot, gif, htm, html, ico, jpeg, jpg, js, otf, pdf, png, ps, psd, svg, swf, ttf, txt, woff, woff2
ExpirePeriod 1 months
}


Fred
7 February 2017, 15:41
Hi Joe Schmoe,

Thank you for helping me out..

In that case how does hiawatha know which to use?
Directory {
DirectoryID = cache-control-2w
Path = /
Extensions = css, eot, gif, htm, html, ico, jpeg, jpg, js, otf, pdf, png, ps, psd, svg, swf, ttf, txt, woff, woff2
ExpirePeriod 2 weeks
}

or
Directory {
DirectoryID = cache-control-2w
Path = /
Extensions = css, eot, gif, htm, html, ico, jpeg, jpg, js, otf, pdf, png, ps, psd, svg, swf, ttf, txt, woff, woff2
ExpirePeriod 2 weeks
}


How will it decide it ExpirePeriod is 1 month or 2 weeks?
Joe Schmoe
7 February 2017, 16:33
You don't need to use them both on the same VirtualHost since they do the same thing. Just choose the one with the appropriate expiration period.

I'm guessing when the structure changed from using UrlToolkit to using Directory it automatically parsed extensions and removed the query string so you no longer need the second Directory section.
Fred
8 February 2017, 00:27
Thank you Joe
This topic has been closed.