Add option to disable caching for HTML content (#366)
* feat: Global performance improve add no-cache for html * feat: Disable HTML caching * fix: eslint check * Clean uppull/368/head
							parent
							
								
									2b638c24c5
								
							
						
					
					
						commit
						479162576d
					
				|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2020 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -41,6 +41,17 @@ export default (domains, global) => { | |||
|     }; | ||||
|     if (global.logging.accessLog.computed) config['location = /robots.txt'].access_log = 'off'; | ||||
| 
 | ||||
|     if (global.performance.disableHtmlCaching.computed) { | ||||
|         // Disable HTML caching for changes take effect in time
 | ||||
|         config['# Disable HTML caching'] = ''; | ||||
|         const loc = `location ~* \\.(?:${extensions.html})$`; | ||||
|         config[loc] = { | ||||
|             add_header: 'Cache-Control "no-cache"', | ||||
|         }; | ||||
|         if (global.logging.accessLog.computed) config[loc].access_log = 'off'; | ||||
|      } | ||||
|   | ||||
| 
 | ||||
|     if (domains.every(d => d.routing.root.computed)) { | ||||
|         if (global.performance.assetsExpiration.computed === global.performance.mediaExpiration.computed) { | ||||
|             if (global.performance.assetsExpiration.computed) { | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: 'Disable HTML caching', // TODO: translate
 | ||||
|     enableDisableHtmlCaching: 'disable HTML caching', // TODO: translate
 | ||||
|     gzipCompression: 'Gzip Komprimierung', | ||||
|     enableGzipCompression: `${common.enable} Gzip Komprimierung`, | ||||
|     brotliCompression: 'Brotli Komprimierung', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: 'Disable HTML caching', | ||||
|     enableDisableHtmlCaching: 'disable HTML caching', | ||||
|     gzipCompression: 'Gzip compression', | ||||
|     enableGzipCompression: `${common.enable} gzip compression`, | ||||
|     brotliCompression: 'Brotli compression', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default {     | ||||
|     disableHtmlCaching: 'Disable HTML caching', // TODO: translate
 | ||||
|     enableDisableHtmlCaching: 'disable HTML caching', // TODO: translate
 | ||||
|     gzipCompression: 'Compresión Gzip', | ||||
|     enableGzipCompression: `${common.enable} compresión gzip`, | ||||
|     brotliCompression: 'Compresión Brotli', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: 'Disable HTML caching', // TODO: translate
 | ||||
|     enableDisableHtmlCaching: 'disable HTML caching', // TODO: translate
 | ||||
|     gzipCompression: 'Compression Gzip', | ||||
|     enableGzipCompression: `${common.enable} la compression gzip`, | ||||
|     brotliCompression: 'Compression Brotli', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: 'Disable HTML caching', // TODO: translate
 | ||||
|     enableDisableHtmlCaching: 'disable HTML caching', // TODO: translate
 | ||||
|     gzipCompression: 'Kompresja gzip', | ||||
|     enableGzipCompression: `${common.enable} kompresję gzip`, | ||||
|     brotliCompression: 'Kompresja brotli', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: 'Disable HTML caching',  // TODO: translate
 | ||||
|     enableDisableHtmlCaching: 'disable HTML caching',  // TODO: translate
 | ||||
|     gzipCompression: 'Compressão Gzip', | ||||
|     enableGzipCompression: `${common.enable} compressão gzip`, | ||||
|     brotliCompression: 'Compressão Brotli', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: 'Disable HTML caching', // TODO: translate
 | ||||
|     enableDisableHtmlCaching: 'disable HTML caching', // TODO: translate
 | ||||
|     gzipCompression: 'Gzip сжатие', | ||||
|     enableGzipCompression: `${common.enable} gzip сжатие`, | ||||
|     brotliCompression: 'Brotli сжатие', | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2021 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -27,8 +27,10 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: '禁用 HTML 缓存', | ||||
|     enableDisableHtmlCaching: '禁用 HTML 缓存', | ||||
|     gzipCompression: 'Gzip 压缩', | ||||
|     enableGzipCompression: `${common.enable}Gzip压缩`, | ||||
|     enableGzipCompression: `${common.enable} Gzip 压缩`, | ||||
|     brotliCompression: 'Brotli 压缩', | ||||
|     enableBrotliCompression: `${common.enable} Brotli 压缩`, | ||||
|     brotliIsANonStandardModule: 'Brotli 并不是一个 standard NGINX 模块, 请查看 ', | ||||
|  |  | |||
|  | @ -27,6 +27,8 @@ THE SOFTWARE. | |||
| import common from '../../common'; | ||||
| 
 | ||||
| export default { | ||||
|     disableHtmlCaching: 'Disable HTML caching', // TODO: translate
 | ||||
|     enableDisableHtmlCaching: 'disable HTML caching', // TODO: translate
 | ||||
|     gzipCompression: 'Gzip 壓縮', | ||||
|     enableGzipCompression: `${common.enable} Gzip 壓縮`, | ||||
|     brotliCompression: 'Brotli 壓縮', | ||||
|  |  | |||
|  | @ -26,6 +26,23 @@ THE SOFTWARE. | |||
| 
 | ||||
| <template> | ||||
|     <div> | ||||
|         <div class="field is-horizontal"> | ||||
|             <div class="field-label"> | ||||
|                 <label class="label">{{ $t('templates.globalSections.performance.disableHtmlCaching') }}</label> | ||||
|             </div> | ||||
|             <div class="field-body"> | ||||
|                 <div class="field"> | ||||
|                     <div :class="`control${disableHtmlCachingChanged ? ' is-changed' : ''}`"> | ||||
|                         <div class="checkbox"> | ||||
|                             <PrettyCheck v-model="disableHtmlCaching" class="p-default p-curve p-fill p-icon"> | ||||
|                                 {{ $t('templates.globalSections.performance.enableDisableHtmlCaching') }} | ||||
|                             </PrettyCheck> | ||||
|                         </div> | ||||
|                     </div> | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
| 
 | ||||
|         <div class="field is-horizontal"> | ||||
|             <div class="field-label"> | ||||
|                 <label class="label">{{ $t('templates.globalSections.performance.gzipCompression') }}</label> | ||||
|  | @ -154,6 +171,10 @@ THE SOFTWARE. | |||
|     import PrettyCheck from '../inputs/checkbox'; | ||||
| 
 | ||||
|     const defaults = { | ||||
|         disableHtmlCaching: { | ||||
|             default: false, | ||||
|             enabled: true, | ||||
|         }, | ||||
|         gzipCompression: { | ||||
|             default: true, | ||||
|             enabled: true, | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| /* | ||||
| Copyright 2020 DigitalOcean | ||||
| Copyright 2022 DigitalOcean | ||||
| 
 | ||||
| This code is licensed under the MIT License. | ||||
| You may obtain a copy of the License at | ||||
|  | @ -37,4 +37,5 @@ export const extensions = { | |||
|         'docx?|dotx?|docm|dotm|' + | ||||
|         'xlsx?|xltx?|xlsm|xltm|' + | ||||
|         'pptx?|potx?|pptm|potm|ppsx?', | ||||
|     html: 'html?', | ||||
| }; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 ChenYuhao
						ChenYuhao