Before i start the questions, here are a couple of things to note about the site (i know how to solve that):
- The pages have no userbased views. (logged-in / not-logged-in)
- Some pages would need to be refreshed on a certain time.
- a cache file would need to be cleared if a document is published/unpublished/deleted/undeleted/modified. (plugin)
- a cache file would need to be cleared if its date has expired.
Performance
- Perfomance is 170ms to 350ms per pageload right now. and that is with 1 user... (me)
- Performance with full page cache would be 11-17 ms.
The technique 1 - rewrite rule
(have omitted security explainations)
1. Apache rewrite
Check if file exists -> Serve file if true, else, index.php?q=....
example:
http://site.com/fragment1/fragment2
looks after fragment1/fragment2/index.php
looks after fragment1/fragment2/index.html
looks after cache/fragment1/fragment2/index.php
looks after cache/fragment1/fragment2/index.html
doesnt exist? the normal rewrite rule would apply:
index.php?q=....
The technique 2 - Cache files
if request reaches index.php?q=.... there are 2 different ways i would
save the cache.
as /cache/fragment1/fragment2/index.php (if the resource expires in some way or another)
as /cache/fragment1/fragment2/index.html (if the resource does not expire)
This way i could completely avoid to use PHP if the resource allows it and serve it a bit faster / use fewer resources. If the file is PHP there would be a simple check inside that checks current date with the cache files expire date...
The technique 3 - Save the cache
Here is where my question comes... (I know how to create directories and save files.)
But i don't know how to get the full page HTML...
One technique I have previously used is to use ob_start("save_file"); ....contents.... ob_end_flush();
( save_file function, which is called on ob_end_flush would then check if the resource is cachable, if it is expirable, compress / html, save the file and return the contents.. )
Next time a request would be made, to that resource, the file would be there in compressed form.
I don't want to modify the core, if I can avoid it.
So... How do I to get the get the full page HTML?
The technique 4 - clearing the cache
To maintain the cache i would add a plugin that clears the specific cache for the resource if applicable.
I really hope anyone has an answer.
Thanks in advance.
Milou
[ed. note: MODXsammy last edited this post 15 years, 1 month ago.]