Skip to content

Commit 139f515

Browse files
committed
index.html
1 parent 307d770 commit 139f515

4 files changed

Lines changed: 125 additions & 0 deletions

File tree

_navbar.md

Whitespace-only changes.

_sidebar.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1+
* 网络
2+
* [理解TCP和UDP](./docs/network/理解TCP和UDP.md)
3+
4+
* Java核心基础
5+
* [理解抽象类与接口](./docs/java/Java关键字理解.md)
6+
* [ConcurrentHashMap实现原理](./docs/java/理解动态代理.md)
7+
* [HashMap为什么是线程不安全的?.md](./docs/java/理解抽象类与接口.md)
8+
9+
* 集合
10+
* [Java集合容器](./docs/java/Java集合容器.md)
11+
* [HashMap原理分析](./docs/java/HashMap原理分析.md)
12+
* [HashMap为什么是线程不安全的?.md](./docs/java/HashMap为什么是线程不安全的.md)
13+
* [ConcurrentHashMap实现原理](./docs/java/ConcurrentHashMap实现原理.md)
14+
15+
* JVM
16+
* [垃圾回收器](./docs/jvm/垃圾回收器.md)
17+
* [垃圾回收算法](./docs/jvm/垃圾回收算法.md)
18+
* [类加载机制](./docs/jvm/类加载机制.md)
19+
* [Java内存模型](./docs/jvm/Java内存模型.md)
20+
* [Java运行时内存划分](./docs/jvm/Java运行时内存划分.md)
21+
* [JVM确认可回收对象的方式](./docs/jvm/JVM确认可回收对象的方式.md)
22+
23+
* 数据库
24+
* [SQL进阶](./docs/database/SQL进阶.md)
25+
* [常见SQL优化方式](./docs/database/常见SQL优化方式.md)
26+
* [MySQL基础概念](./docs/database/MySQL.md)
27+
* [如何使用索引](./docs/database/如何使用索引.md)
28+
* [什么情况下索引会失效](./docs/database/什么情况下索引会失效.md)
29+
* [什么时候不需要创建索引](./docs/database/什么时候不需要创建索引.md)
30+
* [B树与B+树详谈](./docs/database/B树与B+树详谈.md)
31+
* [Hash索引与B+树索引的区别](./docs/database/Hash索引与B+树索引的区别.md)
32+
* [如何使用EXPLAIN查看执行计划](./docs/database/如何使用EXPLAIN查看执行计划.md)
33+
34+
35+
36+
137
* [Java核心面试题汇总](./docs/Interviewquestions/Java核心面试题汇总.md)
238

index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636

3737
}
3838
</script>
39+
40+
<script>
41+
if (typeof navigator.serviceWorker !== 'undefined') {
42+
navigator.serviceWorker.register('sw.js')
43+
}
44+
</script>
3945
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
4046
<!-- 全文搜索-->
4147
<script src="https://cdn.bootcss.com/docsify/4.5.9/plugins/search.min.js"></script>

sw.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* ===========================================================
2+
* docsify sw.js
3+
* ===========================================================
4+
* Copyright 2016 @huxpro
5+
* Licensed under Apache 2.0
6+
* Register service worker.
7+
* ========================================================== */
8+
9+
const RUNTIME = 'docsify'
10+
const HOSTNAME_WHITELIST = [
11+
self.location.hostname,
12+
'fonts.gstatic.com',
13+
'fonts.googleapis.com',
14+
'cdn.jsdelivr.net'
15+
]
16+
17+
// The Util Function to hack URLs of intercepted requests
18+
const getFixedUrl = (req) => {
19+
var now = Date.now()
20+
var url = new URL(req.url)
21+
22+
// 1. fixed http URL
23+
// Just keep syncing with location.protocol
24+
// fetch(httpURL) belongs to active mixed content.
25+
// And fetch(httpRequest) is not supported yet.
26+
url.protocol = self.location.protocol
27+
28+
// 2. add query for caching-busting.
29+
// Github Pages served with Cache-Control: max-age=600
30+
// max-age on mutable content is error-prone, with SW life of bugs can even extend.
31+
// Until cache mode of Fetch API landed, we have to workaround cache-busting with query string.
32+
// Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190
33+
if (url.hostname === self.location.hostname) {
34+
url.search += (url.search ? '&' : '?') + 'cache-bust=' + now
35+
}
36+
return url.href
37+
}
38+
39+
/**
40+
* @Lifecycle Activate
41+
* New one activated when old isnt being used.
42+
*
43+
* waitUntil(): activating ====> activated
44+
*/
45+
self.addEventListener('activate', event => {
46+
event.waitUntil(self.clients.claim())
47+
})
48+
49+
/**
50+
* @Functional Fetch
51+
* All network requests are being intercepted here.
52+
*
53+
* void respondWith(Promise<Response> r)
54+
*/
55+
self.addEventListener('fetch', event => {
56+
// Skip some of cross-origin requests, like those for Google Analytics.
57+
if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) {
58+
// Stale-while-revalidate
59+
// similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
60+
// Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
61+
const cached = caches.match(event.request)
62+
const fixedUrl = getFixedUrl(event.request)
63+
const fetched = fetch(fixedUrl, { cache: 'no-store' })
64+
const fetchedCopy = fetched.then(resp => resp.clone())
65+
66+
// Call respondWith() with whatever we get first.
67+
// If the fetch fails (e.g disconnected), wait for the cache.
68+
// If there’s nothing in cache, wait for the fetch.
69+
// If neither yields a response, return offline pages.
70+
event.respondWith(
71+
Promise.race([fetched.catch(_ => cached), cached])
72+
.then(resp => resp || fetched)
73+
.catch(_ => { /* eat any errors */ })
74+
)
75+
76+
// Update the cache with the version we fetched (only for ok status)
77+
event.waitUntil(
78+
Promise.all([fetchedCopy, caches.open(RUNTIME)])
79+
.then(([response, cache]) => response.ok && cache.put(event.request, response))
80+
.catch(_ => { /* eat any errors */ })
81+
)
82+
}
83+
})

0 commit comments

Comments
 (0)