H5的 多线程Worker,缓存cache
来源:互联网 发布:oracle数据库导出 编辑:程序博客网 时间:2024/06/09 02:27
worker详细
cache详细
web worker 是运行在后台的 JavaScript,独立于其他脚本,不会影响页面的性能。您可以继续做任何愿意做的事情:点击、选取内容等等,而此时 web worker 在后台运行。
worker
交给worker.js 处理 , 数据返回给html
<!DOCTYPE html><html lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> <style type="text/css"> * {margin: 0; padding: 0;} a {text-decoration: none;} ul,li {list-style: none;} body {font-family: "Microsoft yahei";} </style></head><body> <button id="btn">worker</button> <div id="box"></div> <script type="text/javascript"> btn.onclick = function (e) { // 发送postMessage // 外部new Worker() /* web worker 是运行在后台的 JavaScript,独立于其他脚本,不会影响页面的性能。您可以继续做任何愿意做的事情:点击、选取内容等等,而此时 web worker 在后台运行。 */ console.time(1); var w = new Worker('demo.js'); var num = 20000; w.postMessage(num); console.timeEnd(1); w.onmessage = function (e) { box.innerHTML = e.data; } } </script></body></html>
worker.js
// 监听 传输的信息self.onmessage = function (e) { var str = ''; for (var i = 0; i < e.data; i++) { str += String.fromCharCode(i); } self.postMessage(str);}
cache
给Apache /conf/http.conf添加
AddType text/cache-manifest manifest
cache.manifest 文件 后缀名可以是appcache
eg:
//缓存CACHE MANIFEST# time/theme.css/logo.jpg/main.js//联网时NETWORK:login.php//替补FALLBACK:/html/ /offline.html
html文件 中 html 要 添加属性 manifest=”manifest 文件”
<!DOCTYPE html><html manifest="cache.appcache"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title></head><body> <img src="3.jpg" alt="" width="420" height="531"></body></html>
阅读全文
0 0
- H5的 多线程Worker,缓存cache
- 【JavaScript】H5多线程的实现 — Web Worker
- h5 真正的线程worker
- H5 web worker线程的使用
- H5的缓存问题
- H5 web Worker
- 缓存的使用Cache
- Cache缓存的概念
- MyBatis的缓存(Cache)
- Cache【缓存】的使用方法
- Spring Cache的缓存
- 深入理解javascript异步编程障眼法&&h5 web worker实现多线程
- MyBatis的缓存配置(Cache)
- HttpResponseCache的使用 缓存 cache
- spring缓存cache的使用
- 缓存(cache)的理解
- Guava Cache的缓存统计
- Spring Cache 缓存的使用
- Java编程思想之访问权限控制
- NLP解释
- 学习python之 glob模块
- Q125:PBRT-V3,对比VolPathIntegrator::Li()和EstimateDirect()判断Medium的方式
- LeetCode 141. Linked List Cycle
- H5的 多线程Worker,缓存cache
- 读取Java的配置文件Properties
- 封包显示Listview和Imageview
- OpenFlow笔记
- shell脚本--语法篇
- Canonical将确保 Unity 7 能顺利过渡
- 排序相关——荷兰国旗问题
- zoj 1730
- Introduction to R Intro to basics answer