S
S
sergemin2017-04-11 17:46:00
MODX
sergemin, 2017-04-11 17:46:00

How to set up caching?

I'm constantly having cache issues on my site. Displayed without styles. You need to go to the admin panel and clear the cache, then everything works.
I read this article but did not find clear explanations. How to solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roma, 2017-04-13
@B_Roma

I usually configure site caching via .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
ServerSignature Off
#AddDefaultCharset UTF-8
php_value upload_max_filesize 32M
php_value post_max_size 10M
php_value default_charset utf-8
php_value max_execution_time 200
AddHandler application/x-httpd-php .html
AddHandler cgi-script .pl .py .jsp .asp .htm .shtml .sh .cgi
AddType application/x-javascript .js
AddType text/css .css
AddType text/xml .xml
AddType application/octet-stream .doc .mov .avi .pdf .xls
# ForceType application/x-httpd-php
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \. (html?|txt|css|js|php|pl)$
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. *
# Header unset ETag
# Since we're sending expires headers with a long expiration,
# we don't use ETag for static content.
FileETag None
#cache html and htm files for one day
Header set Cache-Control "max-age=43200"
#cache css, javascript and text files for one week
Header set Cache-Control "max-age=604800" #cache
flash and images for month
Header set Cache-Control "max-age=604800"
ExpiresActive Off #default
cache is 5 seconds
ExpiresDefault "access plus 5 seconds"
# cache.appcache can't be cached in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache- manifest "access plus 0 seconds" #cache
flash and images for a month
ExpiresByType image/x-icon "access plus 604800 seconds"
ExpiresByType image/jpeg "access plus 604800 seconds"
ExpiresByType image/gif "access plus 604800 seconds"
ExpiresByType image/gif "access plus 604800 seconds"
ExpiresByType application/x-shockwave-flash "access plus 604800 seconds" #cache
css, javascript and text files for one week
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds" #cache
html and htm files for one day
ExpiresByType text/html "access plus 43200 seconds"
#cache xml files for ten minutes
ExpiresByType application/xhtml+xml "access plus 600 seconds"

S
sanch0ss, 2017-04-20
@sanch0ss

I solved this problem like this
(problem: a site with or without "www" - subsequently the version of the site that was loaded first, that is, which fell into the cache) was correctly displayed)
I simply assign the main domain with www in htaaccess

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.mysite\.by [NC]
RewriteRule (.*) www.mysite.by/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question