Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cachebuster the wrong way around? #32

Closed
robinst opened this issue Dec 3, 2016 · 5 comments
Closed

cachebuster the wrong way around? #32

robinst opened this issue Dec 3, 2016 · 5 comments
Labels

Comments

@robinst
Copy link
Collaborator

robinst commented Dec 3, 2016

Setting params.cachebuster to true results in links like this:

<link rel="stylesheet" href="/css/reset.css">

Setting it to false uses the unix timestamp as a query param, see here. This means clients will have to load the files again when the site is rebuilt. Isn't that supposed to be "cache busting"? Seems the wrong way around.

@nishanths
Copy link
Owner

Thanks for catching. Yes, I made a mistake in this commit: 6e2e423

@nishanths nishanths added the bug label Dec 3, 2016
nishanths added a commit that referenced this issue Dec 3, 2016
@robinst
Copy link
Collaborator Author

robinst commented Dec 4, 2016

Thanks :). With cachebusting turned on, I now get this:

ERROR: 2016/12/04 15:56:32 template.go:132: template: theme/partials/head_includes.html:25:46: executing "theme/partials/head_includes.html" at <.Now.Unix>: can't evaluate field Now in type interface {} in theme/partials/head_includes.html

@nishanths
Copy link
Owner

nishanths commented Dec 4, 2016

Thanks! It looks like .Now does not exist any more. Sigh, it was undocumented anyway.

Even when it did exist, it appears it returned the time associated with the page, not the current time. So cachebuster would not have been working anyway.

Possible solution is to make a pull request to hugo adding a "now" function that returns time.Now().
This is the related code in hugo: https://github.com/spf13/hugo/blob/master/tpl/template_funcs.go#L2018
I'll get to it in a couple of days!

I'll disable cachebuster by default in config.toml until we can sort this out.

@nishanths nishanths reopened this Dec 4, 2016
nishanths added a commit that referenced this issue Dec 4, 2016
nishanths added a commit that referenced this issue Dec 4, 2016
@nishanths
Copy link
Owner

dependent on hugo pr: gohugoio/hugo#2859

@nishanths
Copy link
Owner

Done in 2e598e5.

works for me with hugo 0.18.
@robinst please feel free to reopen if you have issues. thanks for patience!

Related thread for future: https://discuss.gohugo.io/t/proposal-replace-page-now/4968

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants