SPKF Posted June 16, 2014 Share Posted June 16, 2014 (edited) Bonjour à tous, J'ne profite pour vous partager mes regles de cache, très efficace en soit, cependant, elles s'appliquent également au backoffice de prestashop, rendant les choses compliqués, je vous laisse imaginer... Comment éviter que les règles de caches, notamment pour les fichier html, png et jpeg ne s'appliquement tout simplement pas ? Pour info mon repertoire de backoffice se nomme /mybo/ Merci par avance, Mon fichier .htaccess pour le cache : <IfModule mod_expires.c> ExpiresActive On #Les images .jpg seront en cache pour 30 jours ExpiresByType image/jpg "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" #Les images .png seront en cache pour 30 jours ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType image/gif "access plus 2592000 seconds" AddType image/x-icon .ico ExpiresByType image/ico "access plus 2592000 seconds" ExpiresByType image/icon "access plus 2592000 seconds" ExpiresByType image/x-icon "access plus 2592000 seconds" ExpiresByType text/css "access plus 2592000 seconds" ExpiresByType text/javascript "access plus 2592000 seconds" #HTML seront en cache pour 2 HEURES ExpiresByType text/html "access plus 7200 seconds" ExpiresByType application/xhtml+xml "access plus 7200 seconds" ExpiresByType application/javascript A2592000 ExpiresByType application/x-javascript "access plus 2592000 seconds" ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" # Add correct content-type for fonts AddType application/vnd.ms-fontobject .eot AddType application/x-font-ttf .ttf AddType application/x-font-opentype .otf AddType application/x-font-woff .woff AddType image/svg+xml .svg ExpiresByType application/vnd.ms-fontobject "access plus 1 year" ExpiresByType application/x-font-ttf "access plus 1 year" ExpiresByType application/x-font-opentype "access plus 1 year" ExpiresByType application/x-font-woff "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" </IfModule> <IfModule mod_headers.c> <FilesMatch "\\.(ico|jpe?g|JPE?G|png|gif|swf|css|gz)$"> Header set Cache-Control "max-age=2592000, public" </FilesMatch> <FilesMatch "\\.(js)$"> Header set Cache-Control "max-age=2592000, private" </FilesMatch> <filesMatch "\\.(html|htm)$"> Header set Cache-Control "max-age=7200, public" </filesMatch> # DESACTIVATION DU CACHE POUR LES FICHIERS DYNAMIQUES <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$"> Header unset Cache-Control </FilesMatch> </IfModule> # ETag DESACTIVATION Header unset ETag FileETag none <IfModule mod_deflate.c> <IfModule mod_filter.c> SetOutputFilter DEFLATE AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php application/x-font-ttf application/x-font-opentype image/svg+xml #Pour les navigateurs incompatibles BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html #ne pas mettre en cache si ces fichiers le sont déjà SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip #les proxies doivent donner le bon contenu Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> Edited June 16, 2014 by SPKF (see edit history) Link to comment Share on other sites More sharing options...
Mediacom87 Posted June 16, 2014 Share Posted June 16, 2014 Bonjour, faites un htaccess spécifique dans le répertoire admin 1 Link to comment Share on other sites More sharing options...
SPKF Posted June 16, 2014 Author Share Posted June 16, 2014 Super ! mais oui pourquoi je n'y ai pas pensé ! Ca fonctionne très bien. Dorénavant, seul les CSS et les JS sont mis en cache, ce qui accélère notoirement le BO sans pour autant créer des "decalages d'affichage". Merci pour votre précieuse aide. 1 Link to comment Share on other sites More sharing options...
Mister Denial Posted September 9, 2014 Share Posted September 9, 2014 Bonjour, avez vous un exemple du fichier htaccess que vous avez mis dans le répertoire admin? J'ai le même problème sous 1.6.0.9, à cause du cache quand je fais une modif en BO je dois forcer le browser à faire un refresh pour voir les changements, très frustrant. Je n'ai aucune idée du code à mettre dans le deuxième htaccess, donc votre aide serait plus que bienvenue! :-) Merci d'avance! Daniel Link to comment Share on other sites More sharing options...
SPKF Posted September 9, 2014 Author Share Posted September 9, 2014 # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www.prestashop.com - http://www.prestashop.com/forums <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/jpg A0 ExpiresByType image/jpeg A0 ExpiresByType image/png A0 ExpiresByType image/gif "A0 AddType image/x-icon .ico ExpiresByType image/ico "access plus 2592000 seconds" ExpiresByType image/icon "access plus 2592000 seconds" ExpiresByType image/x-icon "access plus 2592000 seconds" ExpiresByType text/css "access plus 2592000 seconds" ExpiresByType text/javascript "access plus 2592000 seconds" ExpiresByType text/html A0 ExpiresByType application/xhtml+xml A0 ExpiresByType application/javascript A2592000 ExpiresByType application/x-javascript "access plus 2592000 seconds" ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" # Add correct content-type for fonts AddType application/vnd.ms-fontobject .eot AddType application/x-font-ttf .ttf AddType application/x-font-opentype .otf AddType application/x-font-woff .woff AddType image/svg+xml .svg ExpiresByType application/vnd.ms-fontobject "access plus 1 year" ExpiresByType application/x-font-ttf "access plus 1 year" ExpiresByType application/x-font-opentype "access plus 1 year" ExpiresByType application/x-font-woff "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" </IfModule> <IfModule mod_headers.c> <FilesMatch "\\.(ico|css|gz)$"> Header set Cache-Control "max-age=2592000, public" </FilesMatch> <FilesMatch "\\.(js)$"> Header set Cache-Control "max-age=2592000, private" </FilesMatch> # DESACTIVATION DU CACHE POUR LES FICHIERS DYNAMIQUES <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi|html|xhtml|pdf|xml)$"> Header unset Cache-Control </FilesMatch> </IfModule> # ETag DESACTIVATION Header unset ETag FileETag none <IfModule mod_deflate.c> <IfModule mod_filter.c> SetOutputFilter DEFLATE AddOutputFilterByType DEFLATE text/css application/x-javascript application/x-httpd-php application/x-font-ttf application/x-font-opentype image/svg+xml #Pour les navigateurs incompatibles BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html #ne pas mettre en cache si ces fichiers le sont déjà SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip #les proxies doivent donner le bon contenu Header append Vary User-Agent env=!dont-vary </IfModule> </IfModule> #If rewrite mod isn't enabled ErrorDocument 404 /index.php?controller=404 # ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again C'est quasiment la même chose, on désactive les images et le html sous tout ses versions pour laisser que css/font/ico/js en cache. Il y a surement moyen de rewrite par rapport a l'arborescence parente et d’alléger le .htaccess mais cette solution me convient bien pour le moment. 1 Link to comment Share on other sites More sharing options...
Mister Denial Posted September 10, 2014 Share Posted September 10, 2014 Merci pour l'info, je l'ai mis en application sur mon site, ca semble effectivement résoudre des problèmes de caching en BO, surtout en ce qui concerne la mise à jour du Dashbord, les nouvelles commandes et même la modification de contenu CMS. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now