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

serve static with CDN #736

Open
4 tasks done
lookis opened this issue Jun 7, 2022 · 5 comments · May be fixed by #2467
Open
4 tasks done

serve static with CDN #736

lookis opened this issue Jun 7, 2022 · 5 comments · May be fixed by #2467
Labels
enhancement New feature or request stale

Comments

@lookis
Copy link

lookis commented Jun 7, 2022

Is your feature request related to a problem? Please describe.

It's a feature request for better performance

Describe the solution you'd like

I would like to serve the static assets with CDN domains, maybe add some settings like cdnURL ?

Describe alternatives you've considered

No response

Additional context

No response

Validations

@kiaking
Copy link
Member

kiaking commented Jun 13, 2022

Hi! Thanks for the feedback. But I'm not sure what you're looking for here 👀 Assets you mean you would like to do ![](https://cdn.com/filename.jpg)...? In that case I think you alredy can? Can you elaborate a bit more?

@kiaking kiaking added the need more info Further information is requested label Jun 13, 2022
@lookis
Copy link
Author

lookis commented Jun 13, 2022

@kiaking thanks for your reply, as you can see, vitepress generate dist folder with assets (js/css) in it, and the html refer these js/css with relative path:

Screen Shot 2022-06-13 at 22 21 06

and I want to serve these static file with cdn server like these:

    <link rel="stylesheet" href="http://some.cdn.server/docs/assets/style.e172b030.css">
    <link rel="modulepreload" href="http://some.cdn.server/docs/assets/app.2986626d.js">
    <link rel="modulepreload" href="http://some.cdn.server/docs/assets/guide_api.md.48406c4b.lean.js">

if i change base config to the cdn link prefix, all links to html will be the cdn address too, which is not I want.

So, i think we can add cdn prefix for generated assets to speed up file loading

@kiaking
Copy link
Member

kiaking commented Jun 14, 2022

Ah OK. So basically you want everything but html files to served from different domain. It might be easy to do this for imported assets like images but might be more complicated on generated js files since we need to modify manifest json as well...?

How do you deploy the site? Do you push assets folder to CDN provider after the build? Or is your hosting service take care these things?

@lookis
Copy link
Author

lookis commented Jun 14, 2022

Yes, you got it.

In my case, my cdn provider will pull the resource from origin server if assets missing, So, I don't need to push these files as long as the file with hash in it's name.

@kiaking kiaking added enhancement New feature or request and removed need more info Further information is requested labels Jun 14, 2022
@kiaking
Copy link
Member

kiaking commented Jun 16, 2022

Gotcha. Thanks for the info!

I think this is not that easy issue to solve, but if anyone wants to tackle it. PR welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants