มาลองเสริมประสิทธิภาพให้กับ .htaccess ด้วย Gzip & Cache กันใน PrestaShop 1.4

ให้นำเอา code ด้านล่างนี้ไปวางไว้ที่ Back Office > Tools > Generators ในช่องของ Specific configuration จากนั้นก็สั่ง Generate .htaccess file ตามปกติครับ สามารถใช้งานร่วมกับ Smarty Cache ได้ครับ เปิดได้ที่ Back Office > Preferences > Performance ในช่อง Force compile = No และ Cache = Yes ครับ

ขอบคุณ Chaitat จาก Group PrestaShop Thailand สำหรับทิปดีๆ ครับ

# ----------------------------------------------------------------------
# Gzip compression
# ----------------------------------------------------------------------
	# force deflate for mangled headers
	# developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
			SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)s*,?s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
			RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding

	# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
		FilterDeclare COMPRESS
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
		FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
		FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
		FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
		FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
		FilterChain COMPRESS
		FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
		# Legacy versions of Apache
		AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
		AddOutputFilterByType DEFLATE application/javascript
		AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
		AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
		AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype# ----------------------------------------------------------------------
# Expires headers (for better cache control)
# ----------------------------------------------------------------------

#
# These are pretty far-future expires headers
# They assume you control versioning with cachebusting query params like:
#