0

我对 Laravel4 有疑问。我基于 Laravel4 Bootstrap Starter ( https://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site ) 为合作伙伴创建了简单的网站。问题是该站点位于两个不同的心理服务器中,它们前面有负载均衡器。Basset 在 public/assets/compiled 中生成 CSS&JS 文件,但我在不同的服务器上有不同的校验和。

因此,它有时从 server1 加载 CSS 文件,有时从 server2 加载。当 S1 和 CSS 文件由 S2 生成 HTML 时,会出现 404 错误。

你可以在这里看到这个问题的例子:http: //affiliate.pirrit.com(刷新几次)

4

1 回答 1

0

I'm not sure how basset works, but if you can output the file name (not the HTML, the actual file) without the hash, you can use H5BP's rewrite rule to use the hash in HTML and route to actual file. This gives you the benefit of cache-busting without the pitfalls you're experiencing of being behind a load balancer.

There's an nginx version also as your server (or at least your load balancer) appears to be nginx.

Lastly, this if off-topic,

  1. Have you made sure that your sessions are "sticky" (or made sure your sessions are persistent on a central storage?). Load balancing tends to mess that up unless care is taken
  2. Every web request has the potential to look like its coming from the same user (aka your load balancer) unless the user's useragent/IP address is passed through to your origin servers.

Just mentioning that in case you run into it as well. It's completely off-topic to your Basset issue. It's something I've run into a bunch.

于 2013-10-09T19:28:33.250 回答