Problem with caching font in htaccess file - .htaccess

I set up this code in .htaccess file but woff font doesn't cache.
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# Web fonts
AddType application/x-font-ttf ttc ttf
AddType application/x-font-woff .woff
AddType application/font-woff2 .woff2
AddType image/svg+xml .svg
AddType application/vnd.ms-fontobject eot
# Embedded OpenType (EOT)
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType font/eot "access plus 1 month"
# OpenType
ExpiresByType font/opentype "access plus 1 month"
# TrueType
ExpiresByType application/x-font-ttf "access plus 1 month"
# Web Open Font Format (WOFF) 1.0
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType font/woff "access plus 1 month"
# Web Open Font Format (WOFF) 2.0
ExpiresByType application/font-woff2 "access plus 1 month"
</IfModule>
Response Header
Accept-Ranges: bytes
Content-Length: 2416
Content-Type: application/font-woff
Date: Sun, 23 Jun 2019 05:39:21 GMT
Last-Modified: Mon, 05 Nov 2018 15:58:57 GMT
Server: Apache/2.4.18 (Ubuntu)
I've also tried without ExpiresActive on and ExpiresDefault "access plus 1 month" but still not working again. What's the problem? How can I cache this kind of font? Other objects such as CSS, JS and all images cached properly by Cache-Control method but I still unable to cache woff fonts.

Fixed the problem by this code:
<filesMatch ".(jpg|jpeg|png|gif|ico|svg|ttf|eot|woff|woff2)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>

Is the htaccess read at all? Place some gibberish in the first line and check if the server responds with a 500 error.

Related

Serve static assets with an efficient cache policy - Google PageSpeed Insights

I am using OctoberCMS and I have apache server and using AWS and when I do PageSpeed testing https://developers.google.com/speed/pagespeed/insights/?url=https%3A%2F%2Fwww.rosterelf.com%2F&tab=desktop I am keep getting this errror saying
Serve static assets with an efficient cache policy
Here is my .htaccess file code to counter this error.
.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_headers.c>
<If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">
Header always set Strict-Transport-Security "max-age=31536000"
</If>
</IfModule>
### MY OTHER DEFAULT CODE OF OCTOBERCMS WHICH IS NOT RELATED TO COMPRESSION ETC ...
</IfModule>
# TN START GZIP COMPRESSION
<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>
# TN END GZIP COMPRESSION
# TN START DEFLATE COMPRESSION
<IfModule mod_deflate.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" \
"application/x-font-opentype" \
"application/x-font-otf" \
"application/x-font-truetype" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/otf" \
"font/ttf" \
"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>
# END DEFLATE COMPRESSION
# TN START ENABLE KEEP ALIVE
<ifModule mod_headers.c>
Header set Connection keep-alive
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
</ifModule>
# TN END ENABLE KEEP ALIVE
# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/svg "access 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/xhtml-xml "access 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"
ExpiresDefault "access 1 month"
</IfModule>
# TN - END EXPIRES CACHING #
But still its keeping this error with 77 resources.
I have tried many things as you can see by adding so much code but yet error count not reducing and its keep getting .js, .png, .css files as well.
Can someone guide me what I am missing here in my code.
Thanks
Updated HTACCESS FILE
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
<IfModule mod_headers.c>
<If "%{REQUEST_SCHEME} == 'https' || %{HTTP:X-Forwarded-Proto} == 'https'">
Header always set Strict-Transport-Security "max-age=31536000"
</If>
</IfModule>
RewriteEngine On
##
## You may need to uncomment the following line for some hosting environments,
## if you have installed to a subdirectory, enter the name here also.
##
# RewriteBase /
</IfModule>
# TN START GZIP COMPRESSION
<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>
# TN END GZIP COMPRESSION
# TN START DEFLATE COMPRESSION
<IfModule mod_deflate.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" \
"application/x-font-opentype" \
"application/x-font-otf" \
"application/x-font-truetype" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/otf" \
"font/ttf" \
"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>
# END DEFLATE COMPRESSION
# TN START ENABLE KEEP ALIVE
<IfModule mod_headers.c>
Header set Connection keep-alive
</IfModule>
# TN END ENABLE KEEP ALIVE
# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType image/svg "access plus 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/xhtml-xml "access plus 1 month"
ExpiresByType text/x-component "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
</IfModule>
<IfModule mod_headers.c>
Header unset ETag
</IfModule>
FileETag None
<IfModule mod_headers.c>
Header unset Last-Modified
</IfModule>
# TN - END EXPIRES CACHING #
But still its keeping this error with 77 resources.
Bear in mind that some of these resources are on external domains for which you have no control.
As stated in the linked document from the PageSpeed results:
When possible, cache immutable static assets for a long time, such as a year or longer.
For one of your .jpg resources .../images/rosterelftechsupport.jpg which is reported by Google's pagespeed insights as being cached for "30 d" it has the following HTTP response headers:
cache-control: max-age=2592000, public
expires: Thu, 12 May 2022 16:05:33 GMT
Whilst the expires header states a cache time of 1 year, the max-age directive of the cache-control header states 30 days (2,592,000 seconds). All modern browsers will prioritise the cache-control: max-age header, so "30 days" is the cache time.
ExpiresByType image/jpeg "access 1 year"
This mod_expires directive sets both the expires and the cache-control: max-age headers on .jpg (mime-type: image/jpeg) files. So, this does seem to be honoured, since the expires header is set correctly and you aren't explicitly setting this anywhere else.
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
However, any Header set Cache-Control (mod_headers) directive, such as this, will override the Cache-Control header set by mod_expires and affect the cache time. So, it would seem you may still have a rogue Header directive?
You certainly don't need both. If you are using mod_expires then only use mod_expires. You do not need mod_headers for this. In other words, you should remove all <FilesMatch ...> Header set Cache-Control ... </FilesMatch> blocks (such as that above) since they are directly conflicting with the mod_expires directives (ie. ExpiresByType).
The only reason to use a mod_headers Header set Cache-Control ... directive is if mod_expires was not available on your server. The only reason to use both mod_expires and mod_headers here is if you are installing your application on multiple servers and it is expected that mod_expires is not installed on all servers (unlikely). In which case, the mod_headers directives should be enclosed inside a <IfModule !mod_expires.c> container (ie. "if mod_expires is not available"), otherwise mod_headers will always take priority (as mentioned above).
You need to make sure the browser and any intermediary proxy caches are clear before testing, since this resource has been cached for "30 days".
UPDATE:
I have removed FilesMatch from file and also checked in my "Private Window" of my browser and opened the website and then ran the "Pagespeed Insights" .. but its still showing around 56 resources not cached including png images etc.
All the .jpg and .png images served from your domain are no longer present in that report, so they would seem to be "resolved".
The remaining 8 .png images that are still showing in the report and have no Cache-Control or Expires headers are being served directly from s3-ap-southeast-2.amazonaws.com - which your directives are not necessarily going to influence. You may need to check the settings on your S3 bucket?
...config/176…?v=2.9.39&r=stable(connect.facebook.net) 20m
You have 7 resources served from external 3rd parties (such as this) which you have no control over.
...industries/nonprofit.svg(www.rosterelf.com) 30 d
ExpiresByType image/svg+xml "access plus 1 month"
You have 22 .svg images served from your domain. These are all served with a image/svg+xml content-type. As you can see from the above ExpiresByType directive these are "only" set to be cached for a period of "1 month" (ie. 30 days). If you want these to be cached for a longer period then change the above directive as you have already done for JPEG and PNG files.
...js/swiper-bundle.min.js(www.rosterelf.com) 30 d
ExpiresByType application/javascript "access plus 1 month"
You have 11 .js files served from your domain - all served with an application/javascript content-type. Change the above ExpiresByType directive accordingly if you want these files to be cached for longer.
HOWEVER, you should note that Google's PageSpeed report is only a "suggestion". Only change this (and other caching directives) if it makes sense for your system. You will have issues if these files need to be changed before the cache expires unless you have implemented some other cache-busting technique.
This also means that the following directives are entirely superfluous and can be removed:
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
Your server is sending .js responses with the correct application/javascript mime-type, so setting caching directives for text/javascript and text/x-javascript as well is not required.
...css/custom.min.css(www.rosterelf.com) 30 d
ExpiresByType text/css "access plus 1 month"
You have 6 .css files served from your domain. The same applies above as for .js files.
... fonts/social-media-icon.ttf?lvmhu5(www.rosterelf.com) 30 d
You have 6 .ttf (font) files. Yes, these should certainly be cached for a longer period. These are all served with an application/font-sfnt*1 mime/content-type. However, you do not explicitly have a directive that covers this, so it will default to the ExpiresDefault (ie. 1 month). You need to add the appropriate directive for this mime-type. For example:
ExpiresByType application/font-sfnt "access plus 1 year"
(*1 application/font-sfnt is actually deprecated in favour of font/sfnt.)
This might mean that all the following (font-caching) directives are superfluous, if you are not serving these file-types?
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/font-woff2 "access plus 1 month"
ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
# Fonts
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType application/font-woff "access plus 1 year"
And to emphasise my comment above... the results from Google's PageSpeed report (and any other SEO report) are only advisory... a possible suggestion. It is not necessarily "wrong" to serve resources with a shorter cache time. These "suggestions" are not meant to be followed blindly. Do not implement long cache times to simply satisfy the report. Only if it makes sense to your application should these resources be cached for longer periods.

Add Expires headers and image optimizaion not updating in siteground hosting

my website available in siteground hosting and i am updating image optimization as per suggestion Gtmetrix and add expire header but still not updating it showing up old
after i have also flush supercacher in hosting but still not updating
my expire header code like
############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
ExpiresActive On
ExpiresDefault "access plus 1 year"
ExpiresByType text/html A0
ExpiresByType text/plain A0
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/css "access plus 14 days"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType text/javascript "access plus 14 days"
ExpiresByType application/x-javascript "access plus 14 days"
ExpiresByType image/ico "access plus 14 days"
ExpiresByType image/jpg "access plus 14 days"
ExpiresByType image/jpeg "access plus 14 days"
ExpiresByType image/gif "access plus 14 days"
ExpiresByType image/png "access plus 14 days"
ExpiresByType image/svg+xml "access plus 1 month"
ExpiresByType text/html "access plus 14 days"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
ExpiresByType application/x-font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/atom+xml "access plus 1 hour"
</IfModule>
Any help would be appreciated.
Thanks.
My name is Georgi Ganchev and I am a Technical Support Supervisor at SiteGround.
I saw your thread and I decided to follow up.
The rules in your .htaccess are correct in general, but we recommend a longer expiration date set for your images, CSS and JS stored locally.
Please check the following article we have written about the most advised configuration:
https://www.siteground.com/kb/leverage-browser-caching/
In case the issue continues, please make sure you open a ticket through the User Area of your account with us and we will gladly help you out.
Best regards,
Georgi Ganchev
Technical Support Supervisor
Siteground.com
We were trying to get a wrong result. i was searching for a solution too but what i found after reading the test result with those lines code and without them:
this code is working but only with internal files.
this code will not work with external files(from other websites like google analytics js ...).
the test result will show you only the external files.
if you remove those lines of codes the result will be worst, and it will result in more files doesn't have an expired age.

Changes in htaccess Expires header not reflecting in browser

I have set all JS on my site to cache for one week. However, there are specific files that I need to be refreshed at a higher frequency. Hence I have used FilesMatch to effect the exception in my .htaccess file:
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
# Favicon (cannot be renamed!)
ExpiresByType image/x-icon "access plus 1 week"
# HTML components (HTCs)
ExpiresByType text/x-component "access plus 1 month"
# HTML
ExpiresByType text/html "access plus 0 seconds"
# JavaScript
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
# Manifest files
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Media
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# Web feeds
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
# Web fonts
ExpiresByType application/font-woff "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresByType application/x-font-ttf "access plus 1 month"
ExpiresByType font/opentype "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
</IfModule>
<FilesMatch "^(ga\.js)$">
ExpiresActive on
ExpiresDefault "access plus 2 days"
</FilesMatch>
The exception file is at /sandboxassets/js/ga.js and the .htaccess I am working with is at the document root (/). However, the browser doesn't seem to honor this exception and gives the following header for the file in question:
Accept-Ranges:bytes
Access-Control-Allow-Origin:*
Age:0
Cache-Control:max-age=604800
Content-Encoding:gzip
Content-Length:11967
Content-Type:application/javascript
Date:Thu, 02 Mar 2017 15:03:55 GMT
Expires:Thu, 09 Mar 2017 15:03:55 GMT
Last-Modified:Thu, 02 Mar 2017 15:00:01 GMT
Server:Apache Phusion_Passenger/4.0.10 mod_bwlimited/1.4 mod_fcgid/2.3.9
Vary:Accept-Encoding,User-Agent
Via:1.1 varnish-v4
X-Varnish:18808880
604800 seconds is 1 week which is the default for all JS assets as defined in my .htaccess but I need it to be 172800 seconds (2 days). What am I doing wrong? Also, is there any way to tell the browser to refresh to the latest header? Opera is returning a 31536000 seconds (1 year) which is what I recently changed to 1 week for all JS!
Update: Using the following code is causing my site to break down completely with an error 500:
<Directory "/sandboxassets/js/">
AllowOverride All
<FilesMatch "ga\.js$">
Expires A172800
</FilesMatch>
<FilesMatch "tww\.js$">
Expires A172800
</FilesMatch>
</Directory>
I added it first inside <IfModule mod_expires.c> and then immediately after it and experienced the same error each time.
My first inclination is that you need to be able to use the 'AllowOverride' within a Directory target block to achieve the override of a specific file.
<Directory "/directory/to/your/file">
AllowOverride All
<FilesMatch "\.js$">
Expires A31536000
</FilesMatch>
</Directory>
Source(s):
http://www.websiteoptimization.com/secrets/advanced/caching-example.html
I highly recommend turning off CloudFlare to do the testing of this before you rule anything out.
It may also be beneficial to check out the answer to this question: https://webmasters.stackexchange.com/questions/9513/htaccess-execution-order-and-priority
I am adding this because I think that it is also possible that this is an ordering issue. .htaccess starts at the root and works its way through the directories.

slider images loading twice after cache control

I have use following code in my .htaccess file for cache control in my joomla site.
########## Begin - ETag Optimization
## This rule will create an ETag for files based only on the modification
## timestamp and their size.
## Note: It may cause problems on your server and you may need to remove it
FileETag MTime Size
# AddOutputFilterByType is now deprecated by Apache. Use mod_filter in the future.
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
# Enable expiration control
ExpiresActive On
# Default expiration: 1 month after request
ExpiresDefault "now plus 1 month"
# CSS and JS expiration: 1 month after request
ExpiresByType text/css "now plus 1 month"
ExpiresByType application/javascript "now plus 1 month"
ExpiresByType application/x-javascript "now plus 1 month"
# Image files expiration: 1 month after request
ExpiresByType image/bmp "now plus 1 month"
ExpiresByType image/gif "now plus 1 month"
ExpiresByType image/jpeg "now plus 1 month"
ExpiresByType image/jp2 "now plus 1 month"
ExpiresByType image/pipeg "now plus 1 month"
ExpiresByType image/png "now plus 1 month"
ExpiresByType image/svg+xml "now plus 1 month"
ExpiresByType image/tiff "now plus 1 month"
ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/ico "now plus 1 month"
ExpiresByType image/icon "now plus 1 month"
ExpiresByType text/ico "now plus 1 month"
ExpiresByType application/ico "now plus 1 month"
ExpiresByType image/vnd.wap.wbmp "now plus 1 month"
ExpiresByType application/vnd.wap.wbxml "now plus 1 month"
cache control started working but i am facing a problem.
Now my slider image is loading two times before appearing. once image is loaded then it again loads ( just like refresh ), but other content is loading correctly.
Please help me out.
I am using DJ-ImageSlider extension of joomla. slider does not slide anything, it just show a single image as a banner.
ETags are difficult because they take precedence for caching in most browsers. You can change all the headers you want, but if the ETag associated with a file is always the same, caching will never work how you expect. In most situations, you should turn your ETag headers off.
Source - David Walsh
So to unset the ETag, you can use the following:
Header unset ETag
and remove this:
FileETag MTime Size
It's difficult to troubleshoot at a distance, but a few ideas you could try.
First make sure you are starting with a clean slate by clearing your browser cache and your Joomla cache, and repeat this step after any changes below.
If problem persists, try going to extensions > module manager > DJ-ImageSlider > Advanced and changing the caching setting.
If still no joy, perhaps play with the cache settings in System > Global Configuration > Cache Settings.
Good luck!

Cache-Control no cache

I have the following from http://web-sniffer.net/ :
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
I use Cloudflare and Custom Expired Rules for caching, but in the browser it seems that they are not caching.
Why is this happening?
Rules:
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# 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 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
It would help if we knew the specific domain name here, also I would recommend opening a support ticket directly with CloudFlare. Our support team can then check your specific account settings, but for obvious privacy reasons can't discuss those here.
Disclaimer: I work at CloudFlare.

Resources