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

Use object ids instead of hashes for Jekyll documents #17

Merged
merged 8 commits into from
May 26, 2020

Conversation

qwtel
Copy link
Contributor

@qwtel qwtel commented May 26, 2020

Proposed solution for #16.

This change drastically improves performance when passing posts, documents or pages, e.g.

{% for post of site.posts %}
  {% included_cached post.html post=post %}
{% endfor %}

The problem with doing the above is the long time it takes to calculate the .hash of a large Jekyll document, such as a post.

However, it should be safe to assume that documents don't change during a page build, so using the object_id instead of the hash for comparison results in a large performance boost.

The implementation only applies to known Jekyll types, so that other complex data still get the old treatment, e.g.

---
data:
  a: 3
  b: 4
---
{% include_cached partial.html data=page.data %}

still works, even if data is passed in multiple places with different object ids.

@welcome
Copy link

welcome bot commented May 26, 2020

Welcome! Congrats on your first pull request to Jekyll Include Cache. If you haven't already, please be sure to check out the contributing guidelines.

Copy link
Owner

@benbalter benbalter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for this.

@benbalter benbalter merged commit 2168263 into benbalter:master May 26, 2020
@welcome
Copy link

welcome bot commented May 26, 2020

Congrats on getting your first pull request to Jekyll Include Cache merged! Without amazing humans like you submitting pull requests, we couldn’t run this project. You rock! 🎉

If you're interested in tackling another bug or feature, take a look at the open issues, especially those labeled help wanted.

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

Successfully merging this pull request may close these issues.

2 participants