I am trying to implement leverage browser cache on a site.I am quite successful in achieving this for desktop optimization ( around 81%), But mobile optimization never crosses 43%.
I am using this url for checking optimization : https://developers.google.com/speed/pagespeed/insights/
My question is: What else can i add to increase optimization on mobile.
Below is the .htaccess file code that i am using
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
# 1 Month for most static assets
#<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
#Header set Cache-Control "max-age=2592000, public"
#</filesMatch>
############################################
## overrides deployment configuration mode value
## use command bin/magento deploy:mode:set to switch modes
# SetEnv MAGE_MODE developer
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
Try this you will gain more speed google page insights,
# Enable Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
</IfModule>
<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>
# Leverage Browser Caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
<IfModule mod_headers.c>
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
Header set Cache-Control "max-age=2678400, public"
</filesmatch>
<filesmatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
<filesmatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</filesmatch>
</IfModule>
Header set Last-Modified "Tue, 31 Aug 2010 00:00:00 GMT"
Could you add following code at the end of .htaccess?
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/x-icon "access plus 1 year"
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"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 year"
ExpiresDefault "access plus 1 month"
</IfModule>
I hope this will work for you.
I am using this in my htaccess file to manage browser caching
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Problem is, it doesnt effect files coming from my local cdn networks, eg
cdn.mydmoain.com
cdn1.mydomain.com
cdn2.mydomain.com
How can i modify my htaccess to manage this?
I cache my website with this code in my .htaccess:
`## EXPIRES CACHING ##
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 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"
## EXPIRES CACHING ##`
The problem is it caches things like my admin area for newsletters etc. Is it possible to modify this code to exclude my admin area (it's in a separate folder). Thank you!
I have an aspx web page with various Telerik RadControls on it and each time this page is loaded, Safari mobile seems to download all the resource files again - for example the following files are downloaded on each page request to an ipad - nothing seems to get cached as it would be on other non-mobile browsers.
http://aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1109/Common/Navigation/NavigationScripts.js
http://aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1109/PanelBar/RadPanelBarScripts.js
http://aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1109/Input/TextBox/RadInputScript.js
http://aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1109/ListBox/RadListBoxScripts.js
http://aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1109/ComboBox/RadComboBoxScripts.js
http://aspnet-scripts.telerikstatic.com/ajaxz/2010.3.1109/Grid/RadGridScripts.js
This is over 100K of javascript being passed down each time even though the CDN resources are set to cache and have ETAGS.
I've rigged up fiddler to both the ipad and a laptop running IE/FF/Safari each time the laptop browser is caching the resource files above and the ipad isn't.
I think this is why my app performs notably slower on the Ipad although it may be the slow javascipt parsing on the Ipad as well...
Has anyone else had this problem? Am i missing something obvious here?
Thanks.
EDIT
I am monitoring the iPad traffic on the laptop by making the laptop an http proxy for the iPad.
Extra Info from fiddler:
Fiddler v2.3.0.0, laptop results from IE8, iPad vers. 3.2.2.
From my laptop, If I go to http://demos.telerik.com/aspnet-ajax/listbox/examples/default/defaultcs.aspx
and after click "First Look" a few times the following in in fiddler:
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom
1 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 54,608 private text/html; charset=utf-8 iexplore:6172
2 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8 iexplore:6172
4 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 54,608 private text/html; charset=utf-8 iexplore:6172
5 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8 iexplore:6172
7 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 54,608 private text/html; charset=utf-8 iexplore:6172
8 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8 iexplore:6172
10 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 54,608 private text/html; charset=utf-8 iexplore:6172
11 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8 iexplore:6172
If I do the same on my iPad the following is recorded by fiddler:
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom
1 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 54,380 private text/html; charset=utf-8
2 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/Common/Navigation/NavigationScripts.js 7,856 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
3 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ComboBox/RadComboBoxScripts.js 16,238 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
4 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/Ajax/Ajax.js 7,509 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
5 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ToolBar/RadToolBarScripts.js 13,372 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
6 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8
8 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 54,380 private text/html; charset=utf-8
9 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/Common/Navigation/NavigationScripts.js 7,856 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
10 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ComboBox/RadComboBoxScripts.js 16,238 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
11 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ListBox/RadListBoxScripts.js 13,199 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
12 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8
13 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ToolBar/RadToolBarScripts.js 13,372 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
15 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 54,380 private text/html; charset=utf-8
16 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/Common/Navigation/NavigationScripts.js 7,856 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
17 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ComboBox/RadComboBoxScripts.js 16,238 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
18 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ToolBar/RadToolBarScripts.js 13,372 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
19 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/ListBox/RadListBoxScripts.js 13,199 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
20 200 HTTP aspnet-scripts.telerikstatic.com /ajaxz/2010.3.1317/Ajax/Ajax.js 7,509 public, max-age=31536000 Expires: Sun, 17 Jan 2021 15:05:25 GMT application/x-javascript
21 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8
EDIT 2:
I have tried exactly the same test as above again today and noticed that:
1) The IPad is now caching the javascript
2) Telerik demos are not using the CDN but they were yesterday! (see results below compared to results above)
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom
1 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 53,036 private text/html; charset=utf-8
2 200 HTTP demos.telerik.com /aspnet-ajax/Telerik.Web.UI.WebResource.axd?compress=1&_TSM_CombinedScripts_=%3b%3bTelerik.Web.UI%2c+Version%3d2010.3.1317.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3a9506cff2-3a86-46c5-b869-6ba1478f3c27%3a1c2121e%3ae8945d51%3af4636213%3ac531f12c%3a4d471440%3af7131199%3ac17ca3a3 10,599 public, max-age=31533429 Expires: Sat, 18 Feb 2012 10:06:39 GMT text/css
3 200 HTTP demos.telerik.com /aspnet-ajax/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d4.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3a8f393b2b-3315-402f-b504-cd6d2db001f6%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%3aen-US%3a9506cff2-3a86-46c5-b869-6ba1478f3c27%3a16e4e7cd%3af7645509%3a24ee1bba%3af46195d3%3a1e771326%3aaa288e2d%3a628ebdd0%3a9cdfc6e7%3aed16cbdc%3a2bef5fcc%3aa7e79140 160,387 public, max-age=31533429 Expires: Sat, 18 Feb 2012 10:06:40 GMT application/x-javascript
4 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8
10 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 53,032 private text/html; charset=utf-8
11 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8
14 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 53,032 private text/html; charset=utf-8
15 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8
18 200 HTTP demos.telerik.com /aspnet-ajax/listbox/examples/default/defaultcs.aspx 53,032 private text/html; charset=utf-8
19 200 HTTP demos.telerik.com /aspnet-ajax/Common/CodeViewer.js.aspx 5,534 private text/javascript; charset=utf-8
I've just tested it with Fiddler - opened a RadListBox on a page with version 2010.3.1109 on an iPad (iOS 4.2) and it seems to me the CDN resources are cached properly and are not refreshed from the CDN every time as you are experiencing.
Can you share some more details about this issue, like a sample page or a live URL where we can test it? You can open a support ticket in your Telerik account to send those if you prefer the privacy.
EDIT:
I've also tested with 3.2.2 and I still can't reproduce this issue. Are you using some specific iPad settings or network setup worth mentioning?