드루팔 7과 PageSpeed


13

Apache 모듈 PageSpeed 는 HTML, JavaScript 등에 대한 다양한 최적화를 제공합니다.

그러나 일부 기능은 Drupal의 자체 집계 및 최적화 방법과 중복됩니다. 그렇다면 어떤 Drupal 7 웹 사이트에 유용한 필터와 Drupal이 이미 지원하고 있기 때문에 쓸모없는 필터를 테스트 한 적이 있습니까?


또한 PageSpeed ​​또는 Drupal이 JS / CSS 집계를 처리하도록하는 것이 더 흥미 롭습니까?
wildpeaks

답변:


9

이것은 내 .htaccess의 PageSpeed ​​섹션입니다.

<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 및 css 압축과 약간의 겹침이 있지만 부정적인 결과는 보이지 않습니다. CSS와 JS를 집계하고 압축하도록 Drupal 7을 설정했습니다.

이 사이트는 특히 트래픽이 많지 않습니다.


한 줄에 필터를로드 할 수도 있지만이 방법으로 가독성을 선호합니다.
Chris Hawes

당으로 code.google.com/speed/page-speed/docs/... insert_img_dimensions가되지 않습니다 당신은 지금 insert_image_dimensions를 사용해야합니다. 또한 내가 알고 있듯이 rewrite_images는 insert_img_dimensions를 포함하는 수퍼 셋입니다.
john

-1

내 htaccess 설정은 다음과 같습니다.

# -----------------------------------------------------------------------
# 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>         
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.