代码之家  ›  专栏  ›  技术社区  ›  Rudraksh Pathak

Gzip压缩不适用于XHR请求

  •  1
  • Rudraksh Pathak  · 技术社区  · 7 年前

    该应用程序托管在AWS环境中,Apache版本为Apache/2.4.18(Ubuntu)。我已经使用启用了压缩。htaccess,它在我的本地系统环境中运行良好。但不是在AWS环境中。

    除了Ajax请求之外,所有其他web请求都使用Gzip在AWS上进行压缩。我是否需要启用其他功能。

    这是。我使用的htaccess代码。

    <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>

    1 回复  |  直到 7 年前
        1
  •  0
  •   Rudraksh Pathak    7 年前

    通过使用解决它 mod_filters 在里面htaccess。把这个贴进去。htaccess-

    <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>