Skip to content

Commit

Permalink
fix: rewrite should only serve cache if upstream is 304
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 27, 2020
1 parent 881b50a commit c3a7a96
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/node/serverPluginModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const modulesPlugin: Plugin = ({ root, app, watcher, resolver }) => {
// only need to rewrite for <script> part in vue files
!((ctx.path.endsWith('.vue') || ctx.vue) && ctx.query.type != null)
) {
if (rewriteCache.has(ctx.url)) {
if (ctx.status === 304 && rewriteCache.has(ctx.url)) {
debugImportRewrite(`${ctx.url}: serving from cache`)
ctx.body = rewriteCache.get(ctx.url)
} else {
Expand Down Expand Up @@ -99,6 +99,7 @@ export const modulesPlugin: Plugin = ({ root, app, watcher, resolver }) => {
// special handling for vue's runtime.
if (id === 'vue') {
const vuePath = resolveVue(root).vue
debugger
await cachedRead(ctx, vuePath)
debugModuleResolution(`vue -> ${getDebugPath(vuePath)}`)
return
Expand Down

0 comments on commit c3a7a96

Please sign in to comment.