WordPress.org

Make WordPress Core

Opened 8 years ago

Last modified 3 years ago

#12491 new enhancement

add a pre_template_include filter, so as to allow caching of the template file

Reported by: Denis-de-Bernardy Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Themes Keywords: has-patch dev-feedback
Focuses: performance, template Cc:

Description

rather than running file exists all over the place in the template loader, we should offer the possibility for a plugin to cache the information for use in subsequent pages.

Attachments (1)

12491.diff (784 bytes) - added by Denis-de-Bernardy 8 years ago.

Download all attachments as: .zip

Change History (10)

#1 @nacin
8 years ago

Patch looks fine, though I'm wondering why you didn't place it above 404 as well, just cause.

More so, couldn't you write to cache on the template_include hook and pull from cache on template_redirect?

Seems like a worksforme, considering that the two hooks now seem more than flexible enough for what you're going for.

#2 @Denis-de-Bernardy
8 years ago

re 404, the point would be to write a plugin that looks up the available template files, caches that accordingly, and knows, based on what the WP Query tells it, what file to use without needing to do a file_exists() call.

template_redirect works fine too for this, up to a point:

  • it would mean the plugin needs to handle robots, feeds, etc. it would also mean the plugin would need to manage whatever we add in there in the future.
  • it would re-introduce the inflexibility that led us to introduce the 2nd hook in the first place, i.e. the plugin itself would not be plugin-able.

#3 @hakre
8 years ago

Additionally, and that is not that visible in the trac patch browser, pre_template_include is building a good pair to template_include, a principle that you can find more and more often within the codebase.

#4 @nacin
8 years ago

Apparently I had misread the diff, and thought 404 was processed before the filter. Obviously, filter comes first in the diff.

#5 @nacin
8 years ago

  • Milestone changed from 3.0 to 3.1

#6 @nacin
8 years ago

  • Milestone changed from Awaiting Triage to Future Release

#7 @nacin
4 years ago

  • Component changed from Optimization to Template
  • Focuses performance added

#8 @nacin
4 years ago

  • Component changed from Template to Themes
  • Focuses template added

#9 @chriscct7
3 years ago

  • Keywords dev-feedback added
Note: See TracTickets for help on using tickets.