Drupal 7 ve Sayfa Hızı


13

Apache modülü PageSpeed HTML, JavaScript ve benzeri için çeşitli optimizasyonlar sağlar.

Bununla birlikte, bazı özellikleri Drupal'ın kendi toplama ve optimizasyon yöntemleriyle gereksizdir. Peki, hangi filtrelerin tipik bir Drupal 7 web sitesi için yararlı olacağını ve Drupal'ın zaten destek sağladığı için hangisinin işe yaramayacağını test eden var mı?


Ayrıca, PageSpeed ​​veya Drupal'ın JS / CSS toplamasını işlemesine izin vermek daha ilginç mi?
wildpeaks

Yanıtlar:


9

Bu benim .htaccess sayfamın PageSpeed ​​bölümüdür:

<IfModule pagespeed_module>
    ModPagespeed on
    ModPagespeedEnableFilters extend_cache
    ModPagespeedEnableFilters collapse_whitespace
    ModPagespeedEnableFilters combine_css
    ModPagespeedEnableFilters move_css_to_head
    ModPagespeedEnableFilters remove_comments
    ModPagespeedEnableFilters inline_css
    ModPagespeedEnableFilters rewrite_javascript
    ModPagespeedEnableFilters insert_img_dimensions
    ModPagespeedEnableFilters rewrite_images
    ModPagespeedEnableFilters rewrite_css
</IfModule>

Js ve css sıkıştırması ile küçük bir çakışma olsa da, herhangi bir olumsuz sonuç görmüyorum. Drupal 7'yi CSS ve JS'yi toplayıp sıkıştırmak üzere ayarladım.

Site, özellikle yüksek trafik değil.


Filtreleri tek bir hatta da yükleyebilirsiniz, ancak bunu bu şekilde yapmanın okunabilirliğini tercih ederim.
Chris Hawes

Gereğince code.google.com/speed/page-speed/docs/... insert_img_dimensions itiraz edildi gibi, şu anda insert_image_dimensions kullanmalıdır. Ayrıca anladığım kadarıyla rewrite_images, insert_img_dimensions içeren bir süper kümedir
john

-1

İşte benim htaccess kurulum:

# -----------------------------------------------------------------------
# Enable keep-alive for faster pagespeed:
# -----------------------------------------------------------------------
<ifModule mod_headers.c> 
    Header set Connection keep-alive 
</ifModule>

# -----------------------------------------------------------------------
# Expire caching
# -----------------------------------------------------------------------
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/pdf "access plus 1 month"
    ExpiresByType application/x-font-woff "access plus 1 year"
    ExpiresByType application/x-font-woff2 "access plus 1 year"
    ExpiresByType application/x-font-ttf  "access plus 1 year"
    ExpiresByType text/x-javascript "access plus 1 month"
    ExpiresByType application/x-shockwave-flash "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresDefault "access plus 2 days"
</IfModule>

# -----------------------------------------------------------------------
# Cache Headers
# -----------------------------------------------------------------------
<ifmodule mod_headers.c>
  # Cache specified files for 31 days
  <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
  Header set Cache-Control "max-age=2678400, public"
  </filesmatch>
  # Cache HTML files for a couple hours
  <filesmatch "\.(html|htm)$">
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  </filesmatch>
  # Cache PDFs for a day
  <filesmatch "\.(pdf)$">
  Header set Cache-Control "max-age=86400, public"
  </filesmatch>
  # Cache Javascripts for 31 days
  <filesmatch "\.(js)$">
  Header set Cache-Control "max-age=2678400, private"
  </filesmatch>
</ifmodule>

# -----------------------------------------------------------------------
# Defining MIME types to ensure the web server actually knows about them.
# -----------------------------------------------------------------------
<IfModule mod_mime.c>
    AddType text/css .css
    AddType application/javascript .js
    AddType application/x-javascript .js
    AddType text/html .html .htm
    AddType text/richtext .rtf .rtx
    AddType image/svg+xml .svg .svgz
    AddType text/plain .txt
    AddType text/xsd .xsd
    AddType text/xsl .xsl
    AddType text/xml .xml
    AddType video/asf .asf .asx .wax .wmv .wmx
    AddType video/avi .avi
    AddType image/bmp .bmp
    AddType application/java .class
    AddType video/divx .divx
    AddType application/msword .doc .docx
    AddType application/x-msdownload .exe
    AddType image/gif .gif
    AddType application/x-gzip .gz .gzip
    AddType image/x-icon .ico
    AddType image/jpeg .jpg .jpeg .jpe
    AddType application/vnd.ms-access .mdb
    AddType audio/midi .mid .midi
    AddType video/quicktime .mov .qt
    AddType audio/mpeg .mp3 .m4a
    AddType video/mp4 .mp4 .m4v
    AddType video/mpeg .mpeg .mpg .mpe
    AddType application/vnd.ms-project .mpp
    AddType application/vnd.oasis.opendocument.database .odb
    AddType application/vnd.oasis.opendocument.chart .odc
    AddType application/vnd.oasis.opendocument.formula .odf
    AddType application/vnd.oasis.opendocument.graphics .odg
    AddType application/vnd.oasis.opendocument.presentation .odp
    AddType application/vnd.oasis.opendocument.spreadsheet .ods
    AddType application/vnd.oasis.opendocument.text .odt
    AddType audio/ogg .ogg
    AddType application/pdf .pdf
    AddType image/png .png
    AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
    AddType audio/x-realaudio .ra .ram
    AddType application/x-shockwave-flash .swf
    AddType application/x-tar .tar
    AddType image/tiff .tif .tiff
    AddType audio/wav .wav
    AddType audio/wma .wma
    AddType application/vnd.ms-write .wri
    AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
    AddType application/zip .zip
    AddEncoding gzip svgz
    #AddEncoding gzip js
    #AddEncoding gzip  css
</Ifmodule>

# -----------------------------------------------------------------------
# Compressing output.
# -----------------------------------------------------------------------
<IfModule mod_deflate.c>
    # Enable compression
    SetOutputFilter DEFLATE

    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|png|jpg|jpeg)$ no-gzip dont-vary
    Header append Vary User-Agent env=!dont-vary    
</IfModule>

# -----------------------------------------------------------------------
#  PageSpeed. - TESTED with Mediacenter
# -----------------------------------------------------------------------
<IfModule pagespeed_module>

    # Turn on mod_pagespeed. To completely disable mod_pagespeed, you
    # can set this to "off".
    ModPagespeed on

    # Direct Apache to send all HTML output to the mod_pagespeed
    # output handler.
    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html

    ModPagespeedLowercaseHtmlNames on
    ModPagespeedEnableFilters extend_cache
    ModPagespeedEnableFilters insert_dns_prefetch
    ModPagespeedEnableFilters add_head
    ModPagespeedEnableFilters add_instrumentation
    ModPagespeedEnableFilters make_google_analytics_async
    #ModPagespeedEnableFilters make_show_ads_async
    ModPagespeedEnableFilters flatten_css_imports

#
# Text / HTML
#

    ModPagespeedEnableFilters collapse_whitespace
    ModPagespeedEnableFilters convert_meta_tags
    ModPagespeedEnableFilters remove_comments
    ModPagespeedEnableFilters collapse_whitespace
    ModPagespeedEnableFilters elide_attributes
    ModPagespeedEnableFilters trim_urls
    ModPagespeedEnableFilters pedantic

#
# JavaScript
#

    ModPagespeedEnableFilters combine_javascript
    #ModPagespeedEnableFilters canonicalize_javascript_libraries
    ModPagespeedEnableFilters rewrite_javascript
    ModPagespeedEnableFilters defer_javascript
    ModPagespeedEnableFilters inline_javascript

#
# CSS
#

    ModPagespeedEnableFilters rewrite_css
    ModPagespeedEnableFilters combine_css
    ModPagespeedEnableFilters move_css_to_head
    ModPagespeedEnableFilters inline_css
    ModPagespeedEnableFilters inline_import_to_link
    ModPagespeedEnableFilters move_css_above_scripts

#
# Images
#

    ModPagespeedEnableFilters inline_preview_images
    ModPagespeedEnableFilters insert_img_dimensions
    ModPagespeedEnableFilters rewrite_images
    ModPagespeedEnableFilters convert_gif_to_png
    ModPagespeedEnableFilters recompress_images
    ModPagespeedEnableFilters recompress_jpeg
    ModPagespeedEnableFilters recompress_png
    ModPagespeedEnableFilters convert_jpeg_to_progressive
    ModPagespeedEnableFilters resize_mobile_images
    ModPagespeedEnableFilters sprite_images
    ModPagespeedEnableFilters lazyload_images
    ModPagespeedEnableFilters local_storage_cache
    ModPagespeedJpegRecompressionQuality 100
    #ModPagespeedEnableFilters responsive_images
    ModPagespeedEnableFilters resize_images

    # Disallow problematic files:
    #ModPagespeedDisallow "*/respond.js"
    #ModPagespeedDisallow "*/lightbox.js*"  

</IfModule>         
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.