Skip to content
Permalink
Browse files
Fix html cache and check copyToDist exist (#304)
* Fix html cache by .htaccess

* Check copyToDist exist
  • Loading branch information
chengshiwen committed Mar 16, 2021
1 parent 438fe9b commit 02e270678022b1f07f154296c3eba8bd7a2143ec
Showing 4 changed files with 27 additions and 5 deletions.
@@ -0,0 +1,23 @@
RedirectMatch 404 /\.htaccess

<FilesMatch "\.html$">
FileETag None
Header unset ETag
Header unset Pragma
Header unset Cache-Control
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
</FilesMatch>

<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType image/png "access plus 1 day"
ExpiresByType image/jpg "access plus 1 day"
ExpiresByType image/jpeg "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType application/javascript "access plus 1 day"
ExpiresByType application/json "access plus 1 day"
ExpiresDefault "access plus 10 days"
</IfModule>
@@ -107,7 +107,9 @@ gulp.task('post-build', (callback) => {
fs.removeSync(path.join(distdir, 'build/manifest.json'), { force: true });
if (Array.isArray(siteConfig.copyToDist)) {
siteConfig.copyToDist.forEach((item) => {
fs.copySync(path.join(__dirname, item), path.join(distdir, item));
if (fs.existsSync(path.join(__dirname, item))) {
fs.copySync(path.join(__dirname, item), path.join(distdir, item));
}
});
}
fs.copySync(path.join(distdir, siteConfig.defaultLanguage, 'index.html'), path.join(distdir, 'index.html'));
@@ -3,7 +3,7 @@ export default {
rootPath: '', // 发布到服务器的根目录,需以/开头但不能有尾/,如果只有/,请填写空字符串
port: 8080, // 本地开发服务器的启动端口
domain: 'dolphinscheduler.incubator.apache.org', // 站点部署域名,无需协议和path等
copyToDist: ['img', 'file', '.asf.yaml', 'sitemap.xml', '.nojekyll'], // 当build发布时,需要额外复制到dist目录的资源,默认有:index.html, 404.html, en-us, zh-cn, build
copyToDist: ['img', 'file', '.asf.yaml', 'sitemap.xml', '.nojekyll', '.htaccess'], // 当build发布时,需要额外复制到dist目录的资源,默认有:index.html, 404.html, en-us, zh-cn, build
docsLatest: '1.3.5', // docs的最新版本,当docs有多个版本时支持latest访问,空则不启用此特性
defaultSearch: 'google', // 默认搜索引擎,baidu或者google
defaultLanguage: 'en-us',
@@ -5,9 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="keywords" content="<%= keywords %>">
<meta name="description" content="<%= description %>">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title><%= title %></title>
<link rel="shortcut icon" href="<%= rootPath %>/img/favicon.ico">
<%_ if (vendorCssPath) { _%>

0 comments on commit 02e2706

Please sign in to comment.