Closed (won't fix)
Project:
Path redirect
Version:
6.x-1.0-rc2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Feb 2007 at 11:03 UTC
Updated:
10 Nov 2011 at 05:29 UTC
Path redirect makes a database call for every page which is a performance issue. I want to redirect only on 404s, page not found. Make .htaccess set 404s to ?documenterror=404&q=. Change Path redirect to check the database only if documenterror set to 404.
Could be an installation option. If Drupal variables are cached and always read then there is no overhead for reading a variable to check the option.
Comments
Comment #1
jjeff commentedUhmm... Don't 404s bootstrap Drupal as well?
The guts of this module happen during hook_init(), which is the first possible hook. And yes, it does one db query per page, but it attempts to be as efficient in this way.
I'm not sure how your scheme would work. In my understanding, the 404 you're referring to wouldn't happen until the end of the Drupal page call, which would be considerably less efficient. Can you explain more?
Comment #2
peterx commentedHello jjjef,
I use redirects only for pages that are missing and they are a very small percentage of overall page accesses. If the path_redirect table was accessed at the end of a page build operation then most page requests would have one less database lookup.
I chopped and changed both my Web site and .htaccess after the previous post. I had directories with files but no index.html and used DirectoryIndex. Now those directories and DirectoryIndex are removed, which removes some odd redirects. All the remaining redirects should be regular 404s which removes the need to pass 403, 404 etc as a parameter.
That leaves just the removal of the database lookup if Drupal is going to find the page. Most visits to my site find a valid page. If the change for redirect could be deferred until Drupal has a change to find a valid page, the database lookup would be rarely required and that should reduce overheads, especially for anonymous users visiting cached pages.
Could the hook be deferred until Drupal decides it is a 404?
includes/common drupal_not_found() looks like the end of the line for a file search but not a page search. I have not found which path Drupal follows when looking for content to create a page. Wherever it goes, there must be an intervention point after Drupal searches for page content and starts creating the 404 error page. If the redirect was inserted there then the path_redirect table would be searched only for pages that are missing.
An occasional lookup for missing pages would be better than always checking for every page.
Comment #3
jjeff commentedIf I'm understanding what you're asking for (and I'm not sure that I am), it sounds like this should be best addressed by a different module than this one.
You want all 404 errors to redirect somewhere?
Moving the redirect to a different hook would affect performance of this module greatly.
I could see adding a 404-redirect case to this module, but honestly, that's such a partitioned piece of functionality that it could (should?) just be another module.
Comment #4
jjeff commentedComment #5
pwaterz commentedan alternative and much cleaner way would to do this would be check if the path is a register drupal path if it is the return. Here is the code to do this, both these function are statically cached so there would be no performance implications.
Comment #6
dave reid