Setting Cache Expires on public/ directory in Mojolicious::Lite

425 views
Skip to first unread message

_lsr

unread,
Jun 19, 2012, 5:22:27 AM6/19/12
to mojol...@googlegroups.com
I'm having trouble wrapping my head around how to set Cache-Control information for images, css and js in my public/ directory. I have an app that is being proxy-ed through apache and I want content in that public/ directory to be cached for a year. Can anyone point my to a howto, my googling skills have failed me on this one.

sri

unread,
Jun 20, 2012, 6:01:12 PM6/20/12
to Mojolicious
> I'm having trouble wrapping my head around how to set Cache-Control
> information for images, css and js in my public/ directory.

An after_static_dispatch hook should do the job.

http://mojolicio.us/perldoc/Mojolicious#hook

--
sebastian

sri

unread,
Jun 20, 2012, 6:17:06 PM6/20/12
to Mojolicious
Since our hook documentation is still a bit sparse i've added an
example.

https://github.com/kraih/mojo/commit/58f5555249950ca0ea5d47bbd276237ed63a5cf5

--
sebastian

_lsr

unread,
Jun 21, 2012, 10:29:51 AM6/21/12
to mojol...@googlegroups.com
Thanks sri that's what I was looking for.

Around the time you posted this I had just stumbled upon this (for posterity) http://toroid.org/ams/etc/mojolicious-static-resources
Reply all
Reply to author
Forward
0 new messages