浏览代码

cache 音频和图片作答

Michael Wang 5 年之前
父节点
当前提交
c6ca6896ff
共有 1 个文件被更改,包括 17 次插入2 次删除
  1. 17 2
      vue.config.js

+ 17 - 2
vue.config.js

@@ -108,10 +108,9 @@ module.exports = {
           },
         },
         {
-          // Match any same-origin request that contains 'api'.
           // logo 地址会变
           urlPattern: new RegExp(
-            "^https://ecs-test-static.qmth.com.cn/org_logo/.*/.*"
+            "^https://ecs(-test)?-static.qmth.com.cn/org_logo/.*/.*"
           ),
           handler: "cacheFirst",
           options: {
@@ -120,6 +119,22 @@ module.exports = {
             },
           },
         },
+        {
+          // 作答文件的地址
+          urlPattern: new RegExp(
+            "^https://ecs(-test)?-static.qmth.com.cn/oe-answer-file/.*"
+          ),
+          handler: "cacheFirst",
+          options: {
+            cacheableResponse: {
+              statuses: [0, 200],
+            },
+            cacheName: "oe-answer-file",
+            expiration: {
+              maxAgeSeconds: 4 * 60 * 60,
+            },
+          },
+        },
         {
           urlPattern: /\/models\/.*\/.*\.json/,
           handler: "cacheFirst",