Welcome to WebmasterWorld Guest from 184.108.40.206
I've got a php include that I have inserted at the end of the pages to do tracking and other housekeeping, but it doesn't output anything to the page itself.
Unfortunately this still forces me to put all the pages through the php interpretor.
Is there any clever way I can use apache (possibly a module in htaccess?) to simply execute the php script AFTER any html page is delivered to a user, therefore keeping their access speedy and a side benefit of truly keeping the pages static, complete with etags, content-length and "last modified"?
Thanks for any ideas!
Is there any clever way I can use apache (possibly a module in htaccess?) to simply execute the php script AFTER any html page is delivered to a user
I might be taking you literally but page is not delivered until all its components were delivered, ie: images, css etc. If you want to run PHP function after that all happens then you can just insert web bug, which would call PHP script that will do some work (log?) and then return 30-40 bytes of invisible GIF.
If however you meant to do some work BEFORE html file is fully delivered then you can use methods described above.
Many third party tracking programs use that technique but since this is my own code I could make it work better.
I can make the image name include the source page name so that it doesn't rely on referers which can be blocked.
But what about folks who block certain kinds of images and the problem of image caching. I know I can make the php script always look new to the browser but sometimes they cache or block the image anyway. Hmnm....
But what about folks who block certain kinds of images and the problem of image caching.
Beat caching by specifying unique name for the image on every page, or append?datestamp to URL - it won't affect nothing. This image can be used for legitimate purpose - some web designers use invisible images and stretch them to create filled rectangles (can't find better term).
So long as its not a 3rd party web bug, and especially functional element of a page it should not be blocked. Word of warning though - referer will be set to that of page for the image request, so you won't get original referer.
AddOutputFilter PHP .html
AddInputFilter PHP .html
php_value auto_append_file /path/logger.php
<? error_log("hello, world");?>
You can do this easily with Perl and mod_perl though.
You can attach a function to run after the content-sending phase. Apache will do everything just like it normally does for static serving- no overhead added- and run your function after the connection is closed. (PerlLogHandler)
It's very, very fast, but you will need to spend some time managing your RAM usage.