Dynamically Update Manifest file based on image uploads in SilverStripe admin

巧了我就是萌 提交于 2019-12-13 04:08:03

问题


I'm new to HTML5's application cache, but am familiar with the basics of it. I'm working on a cache manifest file for a SilverStripe site that needs to be dynamically updated whenever the content manager uploads a new image. I understand that the images will be appended to the Manifest function below using a loop, but the part that I find to be a challenge is updating the date and version number every time. Would I need to have the date and version listed as variables? Or is that not possible considering the setup of the Manifest function?

 public function Manifest() {
      $static = <<<EOT
        CACHE MANIFEST
        # 2016-03-17 v6.0.0
        [manifest content]
      EOT;

       //Append any new image file that gets uploaded
       $static = $static . "\n" . "/test.html";

       $this->response->addHeader("Content-type", "text/cache-manifest");
       return $static;
    }

回答1:


When you change cached by manifest file, the manifest content does not change. However you must change the content to trigger update in a browser. In this case you update a comment. This comment can contain anything. The date and version is common practice, because they reflect the change. So all you need it to get most recent change date from File.LastEdited field.



来源:https://stackoverflow.com/questions/36084893/dynamically-update-manifest-file-based-on-image-uploads-in-silverstripe-admin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!