This is a discussion on Content Negotiation, Caching and PHP within the Apache Web Server forums, part of the Web Server and Related Forums category; Hello! I have quite a technical question and I was hoping one of you Apache Techy guys or gals could ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello!
I have quite a technical question and I was hoping one of you Apache Techy guys or gals could help me... Let me give you a quick summary: I have a PHP script that connects to a database, grabs some data and then creates an XML file. This XML file is then passed through to a XSL stylesheet. The XSL stylesheet that is used is entirely determined on the Accept-Type header from the client. So, if the user-agent can accept XHTML, based on the application/XHTML+XML mime, then the XSL stylesheet myfunction.xhtml.xsl is loaded. If the user-agent prefers HTML, then the XSL stylesheet myfunction.html.xsl is loaded. You get the picture. The result of this PHP script is currently just echoed out. The correct response mime is set and everything is great. However, I'm exploring was in which this PHP script can write the content of the returned document as a file, so that Apaches Content Negotiation can grab the static file rather than execute the PHP script each time. This is pretty straight forward in the PHP script: when the script is called, the content is written into the same directory, and the file myfunction.xhtml is created (or whatever mime type was requested). Now, imagine if you will, this script has been called for pretty much every mime type the function supports, so the directory is full of files, all initially named the same, but the extention is set for compatability with Apache's content negotiation. So, a client requests the URL mysite.com/myfunction, and Apache's content negotiation kicks in and returns the appropriate static file to the client. Awesome. Problem: the data in the database changes, meaning I need the php file to execute again to create the appropriate files. Ideally I'd like to be able to specify that all the myfunction generated static files be "deleted" after, say, an hour since creation, thus forcing Apache to select the PHP file and execute it, resulting in a document being returned to the client, AND a copy being created and stored in the same directoy. Any additional requests would then be caught by Apache's content negotiation and the static file served. I say "deleted" in quotes, as it is not necessarily required that they be phsyically deleted as the PHP script could simply overwrite any existing files. Is it possible that if I delete a static file, can I use content negotiation to default to the PHP file if a file cant be matched (by say, setting the Q value to 0.1 for myfunction.php) and deleting the myfunction.xhtml file? Does anyone understand what I'm babbling about or should I just call the PHP file directly each time, and take the overhead of PHP for each request on the chin? Any thoughts or musings would be appreciated! Cheers, Ben |