Recommended Cache-control / Expires settings

I have noticed that the Piwik js and gif elements take relatively long times to load and I was wondering what I can do to speed the process up.

I am using the following in my htaccess to set the Cache-Control and Expires headers.

############ headers and caching  

<ifModule mod_expires.c>
	ExpiresActive On
	ExpiresDefault A86400
	ExpiresByType image/gif A2592000
	ExpiresByType text/javascript A86400
</ifModule>

### HEADER CACHING 
<ifModule mod_headers.c>
	<FilesMatch "\.(gif|ico)$">
	Header set Cache-Control "max-age=2592000, public"
	</FilesMatch>

	<FilesMatch "\.(js)$">
	Header set Cache-Control "max-age=86400, private, must-revalidate"
	</FilesMatch>

	<FilesMatch "\.(php)$">
	Header set Cache-Control "private, no-store, no-cache, must-revalidate, no-transform, max-age=0"
	Header set Pragma "no-cache"
	</FilesMatch>

# Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
	
# No indexing of Piwik files by robots	
	Header append X-Robots-Tag "noindex"
</ifModule>

<IfModule mod_deflate.c>
    <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE application/javascript \
                                  application/json 
	</IfModule>

	<IfModule mod_setenvif.c>
	# Don't compress images
	SetEnvIfNoCase Request_URI .(?:gif)$ no-gzip dont-vary
	</IfModule>
</IfModule>
############ End of headers and caching

What are the recommendations for these settings, and is there anything else I can do to speed the page loading of the Piwik elements?

If you have medium/high traffic website, see: Optimize and Scale Piwik - Analytics Platform - Matomo

or contact us: We offer support subscriptions for businesses worldwide to make the most out of Piwik analytics. - Analytics Platform - Matomo

No, it’s a low traffic site (so far!). Professional services are way out of my league unfortunately.

Any thoughts on caching / expirey times for the Piwik js, php, and gif elements?

Any advice would be greatly appreciated.

Thanks.

Perhaps I should ask a different question… :wink:

I have static web pages and I am using piwik/js which runs a script and uses a beacon / gif image.
I can see web developer tools that the gif in particular adds approx 1.5s and if I use pingdom the response if even longer for some reason.

Are there any issues with proxy and browser caching the js and the gif?

Are there any specifc advanced settings in WP Super Cache that you would recommend that I select in this case?

Thanks.

the gif taking 1.5s to load is highly unusual, it should take less than 0.5 s normally. Try disabling the PROVIDER plugin. is it better?