本文介绍了根据SilverStripe管理员中上传的图片动态更新清单文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是HTML5应用程序缓存的新手,但熟悉它的基础知识。我正在处理SilverStripe网站的缓存清单文件,每当内容管理器上传新图像时,该文件都需要动态更新。我知道这些图像将使用循环添加到下面的清单功能中,但是我发现遇到的挑战是每次都更新日期和版本号。我需要将日期和版本列为变量吗?还是考虑到清单功能的设置?

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;
    }


推荐答案

更改清单时缓存文件,清单内容不会更改。但是,您必须更改内容才能在浏览器中触发更新。在这种情况下,您将更新评论。此评论可以包含任何内容。日期和版本是常见的做法,因为它们反映了更改。因此,您需要它来从File.LastEdited字段中获取最新更改日期。

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.

这篇关于根据SilverStripe管理员中上传的图片动态更新清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 12:34