Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Since chunks generated from dynamic routes include "~" in their names, cache may not be deleted normally. #7994

Closed
ushironoko opened this issue Aug 31, 2020 · 2 comments

Comments

@ushironoko
Copy link

ushironoko commented Aug 31, 2020

Since nuxt v2.14.0, chunk names of files with a dynamic root seem to fall back automatically to include "~". ref

however, "~" falls under the RFC 1783 unsafe characters. As a result, the cache may not be successfully disabled on certain CDNs (e.g., Amazon Cloud front).

Unsafe:

Characters can be unsafe for a number of reasons.
Character is unsafe because significant spaces may disappear and
insignificant spaces may be introduced when URLs are transcribed or
The characters "<" and ">" are unsafe because they are used as the basis for the treatment of word-processing programs.
The characters "<" and ">" are unsafe because they are used as the
delimiters around URLs in free text; the quote mark (""") is used to
delimit URLs in some systems. The character "#" is unsafe and should
Always be encoded because it is used in the World Wide Web and in other
systems to delimit a URL from a fragment/anchor identifier that might
The character "%" is unsafe because it is used for
Other characters are unsafe because
gateways and other transport agents are known to sometimes modify
These characters are "{", "}", "|", "|", "", "^", "~",
"[", "]", and "`".

https://www.ietf.org/rfc/rfc1738.txt

Non-ASCII or unsafe characters in the path
If the path includes non-ASCII characters or unsafe characters as defined in RFC 1783, URL-encode those characters. Do not URL-encode any other characters in the path, or CloudFront will not invalidate the old version of the updated file.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

It is possible to process the generated chunks in userland (or CI), but I feel this is not a good option.
Alternatively, the documentation should clearly state the measures to be taken in this case.

Versions

  • nuxt: v2.14.1
  • node: v12.18.3

Reproduction

Steps to reproduce

  • Install the latest version of nuxt
  • Create a page SFC file with the usual path(e.g. pages/foo/bar.vue)
  • Follow the instructions in the documentation to set up the deployment configuration ref
  • deploy
  • Create an SFC file with dynamic paths(e.g. pages/foo/_id.vue)
  • When I try to deploy again, I get the following error

Error: Could not invalidate cloudfront: InvalidArgument: Your request contains one or more invalid invalidation paths.

What is Expected?

  • Generates safe chunk names that do not violate rfc1738
  • Cache is successfully invalidate

What is actually happening?

  • Chunks in the dynamic path contain "~" and therefore do not invalidate the CDN cache successfully
@pi0
Copy link
Member

pi0 commented Sep 10, 2020

Hi. This should be resolved with v2.14.5. ~ is webpack's default for joining BTW (only for dev)

@ushironoko
Copy link
Author

@pi0
Thanks for the fix. This issue looks like it can be closed.

~ is webpack's default for joining BTW (only for dev)

I did not know this. Good info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants