# 启动画面卡住，直到硬刷新

**URL:** <https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206>\
**Category:** Support\
**Created:** [2023年四月10日 16:16 UTC](https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206 "2023-04-10T16:16:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanokwa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yanokwa/32/105083_2.png) [@yanokwa](https://meta.discourse.org/u/yanokwa)\
**Post date:** [2023年四月10日 16:16 UTC](https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206/1 "2023-04-10T16:16:59Z")

</div>

我偶尔会看到我运行的论坛显示一个永远无法加载的启动屏幕。

这似乎发生在重建之后，或者如果我长时间没有访问论坛。它似乎与不同的浏览器或论坛插件无关。而且它会发生在一些人身上，但不会发生在另一些人身上。

硬刷新（Windows 上的 Ctrl-F5 或 Mac 上的 Cmd-Shift-R）似乎每次都能解决问题。我猜这与 CDN 的缓存有关，但不确定。还有其他人遇到过类似的情况吗？

页面未加载时的控制台

 ![before](https://global.discourse-cdn.com/meta/original/4X/8/f/b/8fb143717d0e81041e37e160d7f2b55363f7dcaa.jpeg)

硬刷新后的控制台

 ![after](https://global.discourse-cdn.com/meta/original/4X/3/5/8/3589209aaa9a44178e8c3be3471b9a4adbb264ef.png)

---

<div class="post-metadata">

**Author:** ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)\
**Post date:** [2023年四月10日 16:33 UTC](https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206/2 "2023-04-10T16:33:51Z")

</div>

![image](https://global.discourse-cdn.com/meta/original/4X/9/0/4/904f4d63d57900f19068ad17699a4dc074406dcb.jpeg)

所有这些错误都是由于请求被速率限制所致。如果其资源无法加载，Discourse 就无法运行。

您应该检查：

- 是否将正确的最终用户 IP 地址传递给了后端？
- 速率限制是否设置正确？（总体而言）
- 是哪个实体在此处执行速率限制？

---

<div class="post-metadata">

**Author:** ![yanokwa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yanokwa/32/105083_2.png) [@yanokwa](https://meta.discourse.org/u/yanokwa)\
**Post date:** [2023年四月10日 16:56 UTC](https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206/3 "2023-04-10T16:56:07Z")

</div>

对于所讨论的服务器，没有反向代理会隐藏所有用户流量，使其仅显示一个 IP。Discourse 内部设置的速率限制是默认值。

我猜 CDN 可能会进行一些代理？是否有推荐的方法来确认最终用户 IP 是否已传递到后端？我在日志中没有看到任何关于请求过多的信息。

 ![Screenshot 2023-04-10 at 09.55.29](https://global.discourse-cdn.com/meta/original/4X/2/9/6/296c5f4b1b8ec2704c17eb2d49e447dd833d857c.png)

---

<div class="post-metadata">

**Author:** ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)\
**Post date:** [2023年四月10日 17:11 UTC](https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206/4 "2023-04-10T17:11:07Z")

</div>

> [@yanokwa](#):
>
> 对于有问题的服务器，没有反向代理

> [@yanokwa](#):
>
> 我想CDN可能在进行一些代理？

这正是CDN的工作，所以是的，你需要确保正确的最终用户IP在请求链中得到维护。

我猜你没有这样做，并且CDN的所有请求都被计入了CDN POPs的请求速率限制，而不是最终用户的。

![image](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/optimized/4X/3/f/a/3fa8bffcd056f882ed45bfd8f050d71555ad0921_2_690x24.png)

你可以看到CDN在这里返回了429，但你需要调查你的具体设置，以确定是谁决定返回该错误（即代理或真实服务器）。

---

<div class="post-metadata">

**Author:** ![yanokwa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yanokwa/32/105083_2.png) [@yanokwa](https://meta.discourse.org/u/yanokwa)\
**Post date:** [2023年四月14日 21:53 UTC](https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206/5 "2023-04-14T21:53:28Z")

</div>

KeyCDN 是所讨论的 CDN。我尝试启用 [OriginShield](https://www.keycdn.com/support/origin-shield) 并将 `template.yml`（采用 [cloudflare.template.yml](https://github.com/discourse/discourse_docker/blob/main/templates/cloudflare.template.yml) 的风格）添加到我的 `app.yml` 中，但仍然收到 429 错误。

与其继续摆弄它，不如我切换到了 BunnyCDN，它似乎工作得更好。

如果这个模板文件对其他人有帮助，我把它放在下面。

> **keycdn.template.yml**
>
> ```yml
> run:
> - file:
> path: /tmp/add-keycdn-ips
> chmod: +x
> contents: |
> #!/bin/bash -e
> # Add list of keycdn ips
> curl -s 'https://www.keycdn.com/shield-prefixes.json' | \
> python3 -c "import sys, json; print('\n'.join(json.load(sys.stdin)['prefixes']))" > /tmp/keycdn-ips
> 
> # Make into nginx commands and escape for inclusion into sed append command
> CONTENTS=$(< /tmp/keycdn-ips sed 's/^/set_real_ip_from /' | sed 's/$/;/' | tr '\n' '\\' | sed 's/\\/\\n/g')
>         
> echo keycdn IPs:
> echo $(echo | sed "/^/a $CONTENTS")
> # Insert into discourse.conf
> sed -i "/sendfile on;/a $CONTENTS\nreal_ip_header X-Forwarded-For;\nreal_ip_recursive on;" /etc/nginx/conf.d/discourse.conf
> # Clean up
> rm /tmp/keycdn-ips
> 
> - exec: "/tmp/add-keycdn-ips"
> - exec: "rm /tmp/add-keycdn-ips"
> 
> ```

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2023年五月14日 21:53 UTC](https://meta.discourse.org/t/splash-screen-stuck-until-hard-refresh/261206/6 "2023-05-14T21:53:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
