Jump to content

Paramétrer le .htaccess et optimisations diverses d'une boutique


Recommended Posts

Bonjour,

 

Je suis en train de mettre le nez dans le .htaccess afin d'optimiser le site et j'ai quelques questions :

 

1) Doit-on faire une modification sur tous les .htaccess du site ou uniquement celui qui se trouve à la racine du site ?

 

2) Comment mettre en place un parsing afin de différer l'analyse du code JavaScript ?

 

3) Comment mettre en place YUI Compressor et cssmin.js pour réduire la taille des ressources CSS ?

 

Code ajouté dans mon .htaccess :

php_value max_input_vars 5000
# Compression des fichiers XML, XHTML, HTML, JS, CSS, etc
AddOutputFilterByType DEFLATE text/text application/xml application/xhtml+xml text/html text/javascript text/css text/plain
# Mise en cache
<FilesMatch "\.(js|css|gif|jpg|jpeg|png|ico)$">
Header unset Cookie
Header unset Set-Cookie
Header set Cache-Control "max-age=31536000"
Header set vary  "Accept-Encoding"
Header append vary "User-Agent"
Header append Cache-Control "public"
Header append Connection "Keep-Alive"
Header append Keep-Alive "timeout=5, max=100"
FileETag None
</FilesMatch>
# Stop the hotlinking
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mon_site\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /img/nohotlink.jpg [L]
### Caching mod_headers + mod_expires

<IfModule mod_expires.c>

# Turn on Expires and set default to now
ExpiresActive On
ExpiresDefault "now"

# Set up caching on media files for 1 month
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|swf)$">
ExpiresDefault "access plus 1 month"
</FilesMatch>

# Set up caching on images, CSS and JS files for 1 week
<FilesMatch "\.(gif|jpg|jpeg|png|js|css)$">
ExpiresDefault "access plus 1 week"
</FilesMatch>

# Set up 1 hour caching on commonly updated files
<FilesMatch "\.(xml|xsl|html|htm|txt)$">
ExpiresDefault "access plus 1 hour"
</FilesMatch>

# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl)$">
ExpiresActive Off
</FilesMatch>
</IfModule>

<IfModule mod_headers.c>

# Remote ETag from headers
Header unset ETag

# Disable ETag for files
FileETag None

# Media files are catchable
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|swf)$">
Header append Cache-Control "public"
</FilesMatch>

# Images, css and javascript files are catchable
<FilesMatch "\.(gif|jpg|jpeg|png|js|css)$">
Header append Cache-Control "public"
</FilesMatch>

# Commonly updated files are catchable
<FilesMatch "\.(xml|html|htm|txt)$">
Header append Cache-Control "public"
</FilesMatch>

# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>

</IfModule>

PS : J'ai due ajouter une image nohotlink.jpg dans le dossier \img pour utiliser le nohotlink des images

 

5) Dois-je mettre :

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mon_site\.com/

ou

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mon_site.com/

ou autrement ?

 

Merci d'avance pour vos conseils et aides.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...