Jump to content

What gets executed on each page load?


bmacnaughton
 Share

Recommended Posts

I'm sorry if this is dumb question, but I've been trying to find out what gets executed each time PHP serves a page.

The specific scenario is that I'm implementing a LazyCron hook and can put it multiple places - an autoload module, init.inc, site/ready.php, etc.

It has a fair amount of logic to load that I'd prefer not be in every page.

The only way I can see to prevent that code from being loaded and interpreted (not necessarily executed) is to create a special page for it and use a cron job to kick it off only in that page's template.

It seems like ALL autoload modules, init.inc, main.inc, site/ready.php, etc. get loaded and interpreted every page load (unless init.inc is disabled for that template, etc.)

So

1. does everything get loaded and interpreted every page load or is caching of code done in some way (not just the file)?

2. is there a better way to avoid loading significant amounts of code than associating it with a specific page?

Let me know if this isn't clear.

Link to comment
Share on other sites

For your autoload scenario I’ve been doing something similar, but I execute the job via Ajax. That way it doesn’t impact the page load. It’s an extra request, but should go unnoticed by your visitors since you don’t need to wait for a response. Sorry this doesn’t answer your question specifically, but I thought it might be applicable to your scenario.

With regards to caching, ProcessWire will always execute even if it only serves a cached page. That is unless you use ProCache, which allows you to serve cached HTML without invoking PW.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...