How to cachebust static content

87 views
Skip to first unread message

msim...@gmail.com

unread,
Dec 15, 2014, 5:13:58 AM12/15/14
to hippo-c...@googlegroups.com
Hi everyone,

This is an issue we've not yet found a satisfactory solution to.

We've got a bunch of static CSS and images, and after making some updates, we need to cachebust them to force the browser to reload the content. Unfortunately, the simple way of doing the likes of "mysite.css?1" breaks the Channel Manager preview of the site - it's as if it can't read the CSS any more (hst.link didn't like the "?1").

What's the best way of cachebusting static content?

Thanks,
Mark.

Woonsan Ko

unread,
Dec 15, 2014, 8:12:49 AM12/15/14
to hippo-c...@googlegroups.com
Hi Mark,

What do you mean by 'hst.link didn't like the "?1"'?
Do you know you can add param tags inside a link tag?
For example,

<hst:link path="/a/b/c.css">
<hst:param name="v" value="1.0" />
</hst:link>

Regards,

Woonsan
> --
> Hippo Community Group: The place for all discussions and announcements
> about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS:
> https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google
> Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to hippo-communi...@googlegroups.com
> <mailto:hippo-communi...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.


--
w....@onehippo.com www.onehippo.com
Boston - 745 Atlantic Ave, Third Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

Ard Schrijvers

unread,
Dec 15, 2014, 9:52:06 AM12/15/14
to hippo-c...@googlegroups.com
Hey Mark,

I think adding a ? is a pretty brittle solution for cache busting
static resources. What about your css containing for example @import
url("base.css");. The base.css won't be cache busted as it is part of,
say, your style.css.

The HST by itself does not add any expires / cache headers afaik. It
is just default managed by the container (tomcat). We normally add
caching in a proxy like mod_cache / squid / varnish. If your static
files change more frequently than average, set an expires of, say a
day. If that is not good enough, I'd recommend changing the ccs name
when changed during a new deploy, for example rename style.css to
style_v1.css (including imports of course). Also note this is not
really HST specific but just plain container behavior which afaik
every project regardless using HST has to deal with.

Now, for the 7.10, we have moved static resources (optionally) to the
repository, and made it very easy to change them locally (with direct
auto reload in browser). Because we now manage resources and not the
container, we take care of cache busting by prefixing a hash in the
URL. So, for the 7.10, you'd be helped, but you have to wait a little
before the release is available

Regards Ard
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

msim...@gmail.com

unread,
Dec 18, 2014, 6:17:51 AM12/18/14
to hippo-c...@googlegroups.com
Hi Woonsan, Ard,

I wasn't aware you can place parameters inside the hst.link tag, that fixed it, thanks!

I no longer have an example to hand but doing something like (in freemarker) <@hst.link path="/css/mycss.css?1"/> caused the Channel Manager to mis-render the path to the CSS file, breaking the CSS in that view. The site itself was fine, but it makes the CM unusable.

I understand your concern Ard, I realise it's a simplistic way to implement cachebusting. However, I think given how we handle our CSS, we won't suffer from the import problem you shared, and we'd like the amount of control adding variables provides. We don't like the idea of our site being potentially temporarily broken for returning users after an update, and renaming the CSS file feels a little more destructive.

However, I'm looking forward to exploring the static resources changes in 7.10, that sounds even better :). Forgive me if it's already been mentioned, but roughly when could we expect 7.10?

Thanks for your help.
Mark.

Ard Schrijvers

unread,
Dec 18, 2014, 9:59:41 AM12/18/14
to hippo-c...@googlegroups.com
On Thu, Dec 18, 2014 at 12:17 PM, <msim...@gmail.com> wrote:
> Hi Woonsan, Ard,
>
> I wasn't aware you can place parameters inside the hst.link tag, that fixed
> it, thanks!
>
> I no longer have an example to hand but doing something like (in freemarker)
> <@hst.link path="/css/mycss.css?1"/> caused the Channel Manager to
> mis-render the path to the CSS file, breaking the CSS in that view. The site
> itself was fine, but it makes the CM unusable.
>
> I understand your concern Ard, I realise it's a simplistic way to implement
> cachebusting. However, I think given how we handle our CSS, we won't suffer
> from the import problem you shared, and we'd like the amount of control
> adding variables provides. We don't like the idea of our site being
> potentially temporarily broken for returning users after an update, and
> renaming the CSS file feels a little more destructive.
>
> However, I'm looking forward to exploring the static resources changes in
> 7.10, that sounds even better :). Forgive me if it's already been mentioned,
> but roughly when could we expect 7.10?

We expect general availability release in April 2015. Earlier releases
that are not yet marked GA (general availability) will be available
earlier most likely but I cannot completely oversee when exactly

Regards Ard
>> >> <mailto:hippo-communi...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages