Skip to content

Fragment cache#637

Merged
tommy351 merged 1 commit into
devfrom
feature/fragment-cache
Jun 12, 2014
Merged

Fragment cache#637
tommy351 merged 1 commit into
devfrom
feature/fragment-cache

Conversation

@tommy351

Copy link
Copy Markdown
Member

Add fragment cache to improve the performance of file generating. This concept is stolen from Ruby on Rails. The cache will be only enabled in generating mode.

New helper: fragment_cache(id, fn)

<%- fragment_cache('footer', function(){
  return '<footer></footer>';
}); %>

Partial cache

A new option cache will be added to partial helper. This is a shortcut to fragment_cache helper. For example:

<%- partial('footer', {}, {cache: true}) %>

yields:

<%- fragment_cache('footer', function(){
  return partial('footer', {});
}) %>

The effect of fragment cache is remarkable. I used fragment_cache helper in sidebar to reduce database queries. It only took less than 10 seconds to generate 1000+ static files. The original elapsed time is 10 minutes, which means is at least 60x faster.

@tommy351 tommy351 mentioned this pull request May 23, 2014
3 tasks
@tommy351 tommy351 added this to the 2.7 milestone May 23, 2014
@sergiolepore

Copy link
Copy Markdown
Contributor

Great! :)

@floriancargoet

Copy link
Copy Markdown
Contributor

What about caching the article content on disk? Most of the time, only the sidebar changes.
Only the new posts and the changing parts would be rendered to html and then everything is combined.

@tommy351

Copy link
Copy Markdown
Member Author

@floriancargoet This is a great idea. But it may be difficult to implement.

@floriancargoet

Copy link
Copy Markdown
Contributor

I thought of that because that how make works. It checks the last modified date of source files and recompiles only the modified ones (since last compilation), then everything is "concatenated" with the linker.

@tommy351 tommy351 merged commit a63e6f1 into dev Jun 12, 2014
@tommy351 tommy351 deleted the feature/fragment-cache branch June 12, 2014 03:09
@SukkaW SukkaW mentioned this pull request Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants