javascript
档案opcache
git
更新代码和post-hook
请求指定URL
重置opcache
网站A代码:
<script src="https://B/controller/getJsFunction"></script>
网站B代码:
public function getJsFunction()
{
header('Content-Type:application/javascript');
header('Cache-Control: max-age=0, must-revalidate');
//mix('/js/visitor.js') will get visitor.js and auto add the current version
echo file_get_contents(rtrim(public_path(), '/') . mix('/js/visitor.js'));
}
javascript
文件内容javascript
文件版本号,visitor.v1.js
=&gt; visitor.v2.js
B 维持返回502
HTTP
状态代码,
当 B 修改任何代码触发器opcache_reset()
时,即使只是添加评论,bug
也会修复一段时间。
nginx
日志
2018/05/06 03:56:17 [error] 12747#0: *28155344 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: xxxxxxx, server: xxxxxxx.com, request: "GET /stateless/visitor/js HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxxxxx.com", referrer: "https://xxxxxx"
git
收到后
cd /path/to/site-B/project
unset GIT_DIR
git pull origin master && curl https://site-B.com/cache.php
cache.php
<?php
opcache_reset();
nginx.conf
user nginx nginx;
worker_processes auto;
error_log /var/log/nginx/error.log error;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include /etc/nginx/black.ip;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 600;
fastcgi_read_timeout 600;
types_hash_max_size 2048;
client_max_body_size 20m;
gzip on;
index index.html index.htm index.php;
server {
listen 80 default;
server_name _;
return 403;
}
server {
listen 80;
listen 443;
server_name site-b.com;
root /path/to/site-b.com/public;
ssl on;
ssl_certificate /path/to/site-b.com.crt;
ssl_certificate_key /path/to/site-b.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
if ($scheme = http ) {
rewrite ^(.*)$ https://$host$1 permanent;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.(jpg|jpeg|png|gif|js|css|ico|eot|svg|ttf|woff|woff2)$
{
expires max;
add_header Cache-Control public;
add_header Pragma public;
add_header Vary Accept-Encoding;
}
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
reset_opcache()
可以修复错误?或者为什么opcache
会导致此错误? 由于这是一个在线项目,我暂时将其修改为网站A 首次请求网站B 以获取{{1}的当前版本}文件,然后插入javascript
代码并从第一步回复设置script
网址