是否可以(以及如何)缓存 html5

发布于 2024-10-12 15:11:48 字数 191 浏览 1 评论 0原文

我知道这个问题很奇怪,所以让我解释一下。我有一个 html5 应用程序,一个回答问题的化身。然而,虽然不忙,但我希望我的头像显示等待动画。收到了我的视频,它运行得很好,但这是一个 2 秒的视频,我想访问它,而无需每次播放时询问服务器,它的流量太大了。我想要的是下载一次,然后每次需要时都可以播放。有没有办法缓存它?其他解决方案也很受欢迎^^。

谢谢你们

I know this question is rather strange ,so let me explain. I got an html5 application, an avatar that answers questions. However, while not busy, i want my avatar to display a waiting animation. Got my video, and it works just fine, but it is a 2 secs video that i want to access without asking the server every time i have to play it, its just too much traffic. What i want is to download it once, and then be able to play it every time i need. Is there anyway to cache it? Other solutions are wellcomed too ^^.

Thank you guys

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸伞微斜 2024-10-19 15:11:48

我不确定这是否有效,但您可以尝试使用缓存清单。以下是有关如何使用它的信息: http://www.webreference .com/authoring/languages/html/HTML5-Application-Caching/

简单来说:

<!DOCTYPE HTML> 
<html manifest="manifest.cache"> 
....

manifest.cache

#What to cache for reuse
CACHE MANIFEST 
index.html 
stylesheet.css 
images/masthead.png 
scripts/misc.js 

#What to cache in case network goes down (if network is up it will still try to load it from net)
NETWORK: 
search.php 
login.php 
/api 

#What to show when resource is not cached and no way to load it
FALLBACK: 
images/dynamic.php static_image.png 

I am not sure if that works, but you can try using cache manifest. Here is info on how to use it: http://www.webreference.com/authoring/languages/html/HTML5-Application-Caching/

Briefly:

<!DOCTYPE HTML> 
<html manifest="manifest.cache"> 
....

manifest.cache

#What to cache for reuse
CACHE MANIFEST 
index.html 
stylesheet.css 
images/masthead.png 
scripts/misc.js 

#What to cache in case network goes down (if network is up it will still try to load it from net)
NETWORK: 
search.php 
login.php 
/api 

#What to show when resource is not cached and no way to load it
FALLBACK: 
images/dynamic.php static_image.png 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文