Question

I am working on one of the cakephp2 website speed improvement.

now i need to setup some header expire and cache stuff.

but in cakephp in which htaccess I have to put my code.

And please suggest any nice htaccess codes.

I have tried

#Expire Header
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 2 hours"
</FilesMatch>

but its not working, also I have tried couple of other code but none of them working for me.Is there any key configuration that am missing?

One more thing if is there any other tricks to improve performance then please suggest me.

Was it helpful?

Solution

add folowing code to .htaccess file

# cache images/pdf docs for 10 days
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif)$">
  Header set Cache-Control "max-age=864000, public, must-revalidate"
  Header unset Last-Modified
</FilesMatch>

# cache html/htm/xml/txt diles for 2 days
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
  Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>

more information http://tutorialpedia.org/tutorials/Apache+enable+file+caching+with+htaccess.html

OTHER TIPS

below following can add it to modify the .htaccess files in your app/webroot/.htacces folder with impunity.

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType application/x-javascript A8640000
    ExpiresByType text/javascript A8640000
    ExpiresByType text/css A8640000
    ExpiresByType image/png A8640000
</IfModule>

or if you can also see in detail at cakephp.org

hope this will sure help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top