AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1073261
Accepted
Jintor
Jintor
Asked: 2021-08-02 18:01:50 +0800 CST2021-08-02 18:01:50 +0800 CST 2021-08-02 18:01:50 +0800 CST

某些东西“阻止”了我的图像加载更快尝试的 apache 配置、nginx、缓存头的东西,没有任何变化

  • 772

问题:我网站中的图像需要一些时间才能开始加载......就像有什么东西被阻塞了,但无法查明可能是什么原因。

PHP 8 / 最新的 WHM

现场示例:https ://www.stubfeed.com/crypto

我尝试了什么[.0A.]:更改网络托管公司=>没有变化,我的网络代码中有一些东西......

我尝试了什么 [.0B.] :我使用 centos 7 并更改为 centos 8 => 仍然相同

我尝试了什么 [.0C.] :禁用 php-fpm => 它有很大帮助,但仍然需要等待图像。

我尝试了什么 [.0D.]:输出缓冲区打开或关闭 => 仍然相同

我尝试了什么 [.1.] :将我所有的 .css 和 .js 合并到更少的文件中(2.css 2.js 而不是多个)//还添加了 font-display:swap;

我尝试了什么 [.2.]:用于 apache 的 nginx 反向代理(打开或关闭 => 没有变化,因为 cloudflare 充当 CDN ...)

我尝试了什么 [3]:apache 配置

Header set X-XSS-Protection "1; mode=block"
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "no-referrer"
Header always set Permissions-Policy "geolocation=(self),midi=(self),sync-xhr=(self),magnetometer=(self),gyroscope=(self),fullscreen=(self)"

我尝试了什么 [4]:.htaccess 缓存控制标头

<IfModule mod_headers.c>
    ExpiresActive On
    <FilesMatch “\.(webp|webm|flv|ico|pdf|avi|mov|mp4|m4v|m4a|ppt|doc|mp3|wmv|wav|gif|jpg|jpeg|png|apng|swf|css|js|otf|ttf|woff)$">
    Header set Cache-Control "max-age=31536000, public"
    </FilesMatch>
</IfModule>

我尝试了什么[5]:将我的所有图像转换为 webp -quality 60(使用 iMageMagick)=> 它大大减小了尺寸;)==>> 但仍然没有解决问题。

我尝试了什么[6]:在谷歌浏览器控制台中=>“空缓存硬重新加载”=>似乎更快地正常加载???

我尝试了什么 [7]:在 google chrome 控制台 => 网络选项卡 => 我看到从缓存中加载,但不知何故,我看到菜单非常快,但所有其他图像,它等待 1 或 2 秒才显示

我尝试了什么 [8]:在 cloudflare https://www.stubfeed.com/media/中添加页面规则* 浏览器缓存 TTL:一年,缓存级别:缓存所有内容,边缘缓存 TTL:14 天,缓存欺骗装甲:开,源缓存控制:开

我尝试了什么 [9]:加载 4、6、9、23 张图像 => 都一样,仍然:我用眼睛看到的内容(等待 1 秒,然后出现图像..)[速度测试人员说.. .]

我尝试了什么 [10]:缓存所有 fecth 的服务工作者... => 我将其关闭,因为之前从缓存中检查非常慢... :( 你可以在那里看到它:https ://www.stubfeed.com /ws.js?v=202108000021(在可缓存数组中我添加了 wepb,但我删除了它......)

所有这些尝试的结果:菜单、.css、.js ==>> 非常快速和瞬时......但在 1(有时 2)秒后仍然图像......

你可以在这里看到一份报告:https ://gtmetrix.com/reports/www.stubfeed.com/4MGVqAFv/

在此处输入图像描述 在此处输入图像描述

curl -I https://www.stubfeed.com/media/feed/2021/08/02/14463960829226.webp

HTTP/2 200 
date: Mon, 02 Aug 2021 02:13:44 GMT
content-type: image/webp
content-length: 78296
x-content-type-options: nosniff
referrer-policy: no-referrer
permissions-policy: geolocation=(self),midi=(self),sync-xhr=(self),magnetometer=(self),gyroscope=(self),fullscreen=(self)
last-modified: Mon, 02 Aug 2021 01:40:11 GMT
vary: Accept-Encoding
x-xss-protection: 1; mode=block
strict-transport-security: max-age=15552000; includeSubDomains; preload
cache-control: public, max-age=31536000
cf-cache-status: HIT
age: 1483
accept-ranges: bytes
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=QawI6BH%2FlcrvvsUxJ6VgTJzwNqvb%2BVqBRo1gbxng6JRggJe9MgZbkWhLtMjmwvwC8yB3SLaoJXT%2BvNZDuLCzya1g8HlxGFbpFMzXB%2F4p%2B9GcIGIZANk%2FjfvIx0Lu2t07QIsr"}],"group":"cf-nel","max_age":604800}
nel: {"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 6783c9ea7f3c4bd1-YUL
alt-svc: h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400, h3=":443"; ma=86400
website cache apache-2.4 network-speed
  • 1 1 个回答
  • 182 Views

1 个回答

  • Voted
  1. Best Answer
    Jintor
    2021-08-19T17:46:53+08:002021-08-19T17:46:53+08:00

    经过深入挖掘,我找到了它。

    这是我的“步骤”......加载页面然后ajax......

    我重新考虑并做了一个包含。

    我还将我的 ajax 重塑为异步等待

        async function stubajax (divid,phphat,postix = [],pend = 'html') {
        
            var pcache = (Math.floor(Math.random() * 100000000) + 1);
            
            postix["preventcache"] = pcache;
            postix["divid"] = encodeURIComponent(divid);
            postix["mojax_height"] = encodeURIComponent($(window).height());
            postix["mojax_width"] = encodeURIComponent($(window).width());
    
    postix["cookies"] = decodeURIComponent(document.cookie); // if you need to send cookies
            
            for (var i = 0; i < localStorage.length; i++){ postix[localStorage.key(i)] = localStorage.getItem(localStorage.key(i)); }
            for (var i = 0; i < sessionStorage.length; i++){ postix[sessionStorage.key(i)] = sessionStorage.getItem(sessionStorage.key(i)); }
                
            await fetch(phphat+"?pcache="+pcache+"&fetchx="+pcache, {
              method: "POST", body: JSON.stringify(Object.assign({}, postix)), headers: {"Content-type": "application/json; charset=UTF-8"}
            }).then( response => { return response.text(); }).then( html => { 
                switch ( pend ){
                    case 'append' : $("#"+divid+"_message").append(extraforml+html); break;
                    case 'prepend' : $("#"+divid+"_message").prepend(extraforml+html); break;
                    default : $("#"+divid+"_message").html(extraforml+html); break;
                }
            }).catch( err => console.log(err) );
              
        }
    

    以后可以这样调用

    stubajax('id','...php',{'somevar1':'hello'});
    

    //(当灯塔上每个主题达到 100% 时,他们添加了烟花动画)

    在此处输入图像描述

    • 2

相关问题

  • 网站被隐藏的 iframe (q5x.ru) 攻击

  • 设置测试服务器

  • Typo3 网站中的会话超时,无法使用 Mozilla Firefox 打开

  • 虚拟主机建议 [关闭]

  • 谁能推荐一个网站监控服务?[关闭]

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve