【问题标题】:How to speed up an OctoberCMS/Laravel 5.1 Application?如何加速 OctoberCMS/Laravel 5.1 应用程序?
【发布时间】:2017-01-25 14:29:12
【问题描述】:

我正在使用 OctoberCMS(基于 Laravel 5.1 构建的 CMS)。但问题是网站速度很慢。

我缩小了 HTML、CSS、JS 文件,甚至缩小了 octobercms 的库本身,但仍然遇到同样的问题。

我尝试通过编辑.htaccess 文件来缓存静态文件,但当我使用google speed test 对其进行测试时,它速度有点快,但仍然很慢

当我在我的服务器上安装 wordpress 并对其进行测试时,它比我的 OctoberCMS 网站快得多。

有谁知道这是为什么?以及如何解决这个速度问题?

【问题讨论】:

  • 在我看来太宽泛了。要检查的内容太多,无法在一个答案中涵盖。如果这是一个商业网站,请聘请专家,否则请自行开始研究。

标签: php performance .htaccess laravel laravel-5


【解决方案1】:

我尝试了一些在线教程并找到了一个很好的解决方案。

我将此添加到我的.htaccess 文件中。

<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com[NC]

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# HTML
ExpiresByType text/html "access plus 2 days"

# Javascript
ExpiresByType application/javascript "access plus 1 month"

# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"

# CSS
ExpiresByType text/css "access plus 1 month"
</IfModule>

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>


<IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE "application/atom+xml" \
                                  "application/javascript" \
                                  "application/json" \
                                  "application/ld+json" \
                                  "application/manifest+json" \
                                  "application/rdf+xml" \
                                  "application/rss+xml" \
                                  "application/schema+json" \
                                  "application/vnd.geo+json" \
                                  "application/vnd.ms-fontobject" \
                                  "application/x-font-ttf" \
                                  "application/x-javascript" \
                                  "application/x-web-app-manifest+json" \
                                  "application/xhtml+xml" \
                                  "application/xml" \
                                  "font/eot" \
                                  "font/opentype" \
                                  "image/bmp" \
                                  "image/svg+xml" \
                                  "image/vnd.microsoft.icon" \
                                  "image/x-icon" \
                                  "text/cache-manifest" \
                                  "text/css" \
                                  "text/html" \
                                  "text/javascript" \
                                  "text/plain" \
                                  "text/vcard" \
                                  "text/vnd.rim.location.xloc" \
                                  "text/vtt" \
                                  "text/x-component" \
                                  "text/x-cross-domain-policy" \
                                  "text/xml"

</IfModule>

而且网站速度也快了很多。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多