I am new to HTML5 cache manifests and still learning SilverStripe. Right now, I have a project that will require the use of a cache manifest file, and the file will need to be updated as content managers add images in the admin and as they add in youtube video IDs (which I used to get the youtube video preview thumbnails).
Currently I have a HomePage.php file that has the cache manifest set to a variable called $static:
# version should change when new files are added on the Silverstripe end
public function Manifest() {
$static = <<<EOT
CACHE MANIFEST
#$ManifestDate $ManifestVersion
#all jQuery/JavaScript files
themes/simple/javascript/sample.js
#all css files
themes/simple/css/sample.css
#all images files
themes/simple/images/test_image.png
EOT;
//Append the new files to the $static variable here
$this->response->addHeader("Content-type", "text/cache-manifest");
return $static;
}
Here is what I do know so far: I need to update the version # and date every time the user uploads new images or adds new youtube video IDs (hence the $ManifestDate and $ManifestVersion variables). I will append the new files in a loop near the end of the Manifest function. I need to make use of the onAfterWrite() function to pull the information from the database that I need to update the cache manifest content inside the $static variable.
I'm not sure how to proceedd, though, as I am not even sure this is the best way to maintain a cache manifest dynamically in a CMS. Is there a cleaner way to maintain such a file or is this the best approach?