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

Add automatic flushing of rewrites #13

Merged
merged 2 commits into from Aug 22, 2014
Merged

Add automatic flushing of rewrites #13

merged 2 commits into from Aug 22, 2014

Conversation

rmccue
Copy link
Member

@rmccue rmccue commented Jul 8, 2014

This automatically flushes rewrite rules when they need to be. It does this by "generating" them on every request, which could potentially theoretically be slow.

In practice, the slowest part of rewrite rules is deleting the option, and then saving it again, which WP does every time you call flush_rewrite_rules. If your rewrites haven't changed, deleting the option is unnecessary, as update_option can work out whether it needs to actually update the DB/object cache.

This PR automatically flushes rewrite rules for you, if you define HM_REWRITE_AUTOFLUSH as true. This currently defaults to false for backwards compatibility reasons, but setting it to true would be my preferred option.

My findings in practice: there are 179 rules in use on Happytables. This adds ~3ms to page loads, which is negligible at best.

Allows using manually to flush rewrites. This is handy if you want to add
extra features (such as locking) but still use the hooks and better
flushing system.
@rmccue
Copy link
Member Author

rmccue commented Jul 8, 2014

@joehoyle #reviewmerge

Also, thoughts on changing HM_REWRITE_AUTOFLUSH to true?

@joehoyle
Copy link
Member

Nice! Let's leave it experimentally disabled by default for now. I'll be turning this on fo sho

joehoyle added a commit that referenced this pull request Aug 22, 2014
Add automatic flushing of rewrites
@joehoyle joehoyle merged commit 4c882b7 into master Aug 22, 2014
@joehoyle joehoyle deleted the auto-flush branch August 22, 2014 05:47
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.

None yet

2 participants