Open NotBobTheBuilder opened 11 years ago
So, as I mentioned by mail, you'll first need to add to the table defined here: https://github.com/CampFireManager/cfm2/blob/master/classes/Base/Request.php#L28
'text/cache-manifest' => array(
'media' => true, 'rest' => false, 'site' => false
),
It would probably be worth adding an application extension here: https://github.com/CampFireManager/cfm2/blob/master/classes/Base/Request.php#L543
case 'manifest':
$this->setAcceptType(
'text/cache-manifest',
$arrDenyTypes
);
break;
Then, if you can use the /media directory, do so, otherwise, some code in here to handle the manifest file: https://github.com/CampFireManager/cfm2/blob/master/index.php#L37
if ($arrPathItems[0] == 'cache' && $arrPathItems[1] == 'manifest') {
$file = dirname(__FILE__) . '/path/to/cache.manifest';
if (is_file($file)) {
Base_Response::sendResumableFile($file, TRUE, $objRequest->get_strPrefAcceptType());
} else {
Base_Response::sendHttpResponse(404, null, $objRequest->get_strPrefAcceptType());
}
Or, instead of the sendResumableFile, use Base_Response::sendHttpResponse(200, $cache_content, $objRequest->get_strPrefAcceptType()) instead.
Obviously, it's been a while since I've looked at some of this, so some of the functions might not quite work the way I remember they do, but I think this is right.
Cheers for that!
I've just realised - a lot of the files to be cached will need to have their absolute location held in the manifest, so storing them in /media won't work without some manual modification of the manifest.
Is it possible to have the manifest file run through Smarty before being served up?
Er, probably, but you'll have to tweak either Base_Response::render() (I think) or index.php.
To integrate nifty Application Cache stuff, CFM needs to serve a manifest with mime type of "text/cache-manifest". What is the most suitable way to do this?
So far, I've looked at index.php and how it serves mime types according to whether the request is for an image, data from the API or a browser looking for HTML, but there's no obvious way of fitting in the manifest.
It seems a bit "ugly" to hijack the control block from lines 35-90 (which test whether the request is for API or media) just to check if this is a request for the manifest.
Modifying .htaccess so that the manifest request doesn't get redirected through index.php is an option, but it isn't perfect and then requires the server to be configured to serve the "text/cache-manifest" mime type.
Is there a tidier way of doing this?