-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable caching in htaccess #3
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,68 @@ | ||
Options -Indexesorder deny,allowdeny from allallow from 127.0.0.1# Only allow from local IPs:allow from 192.168.0.0/255.255.0.0 | ||
Options -Indexes | ||
|
||
order deny,allow | ||
deny from all | ||
allow from 127.0.0.1 | ||
# Only allow from local IPs: | ||
allow from 192.168.0.0/255.255.0.0 | ||
|
||
# thanks to: https://stackoverflow.com/questions/13028990/htaccess-leverage-browser-caching-for-images-and-css | ||
# Enable Compression | ||
<IfModule mod_deflate.c> | ||
AddOutputFilterByType DEFLATE application/javascript | ||
AddOutputFilterByType DEFLATE application/rss+xml | ||
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject | ||
AddOutputFilterByType DEFLATE application/x-font | ||
AddOutputFilterByType DEFLATE application/x-font-opentype | ||
AddOutputFilterByType DEFLATE application/x-font-otf | ||
AddOutputFilterByType DEFLATE application/x-font-truetype | ||
AddOutputFilterByType DEFLATE application/x-font-ttf | ||
AddOutputFilterByType DEFLATE application/x-javascript | ||
AddOutputFilterByType DEFLATE application/xhtml+xml | ||
AddOutputFilterByType DEFLATE application/xml | ||
AddOutputFilterByType DEFLATE font/opentype | ||
AddOutputFilterByType DEFLATE font/otf | ||
AddOutputFilterByType DEFLATE font/ttf | ||
AddOutputFilterByType DEFLATE image/svg+xml | ||
AddOutputFilterByType DEFLATE image/x-icon | ||
AddOutputFilterByType DEFLATE text/css | ||
AddOutputFilterByType DEFLATE text/html | ||
AddOutputFilterByType DEFLATE text/javascript | ||
AddOutputFilterByType DEFLATE text/plain | ||
</IfModule> | ||
<IfModule mod_gzip.c> | ||
mod_gzip_on Yes | ||
mod_gzip_dechunk Yes | ||
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ | ||
mod_gzip_item_include handler ^cgi-script$ | ||
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.* | ||
</IfModule> | ||
|
||
# Leverage Browser Caching | ||
<IfModule mod_expires.c> | ||
ExpiresActive On | ||
ExpiresByType image/jpg "access 1 month" | ||
ExpiresByType image/jpeg "access 1 month" | ||
ExpiresByType image/gif "access 1 month" | ||
ExpiresByType image/png "access 1 month" | ||
ExpiresByType text/css "access 1 month" | ||
ExpiresByType application/pdf "access 1 month" | ||
ExpiresByType text/x-javascript "access 1 month" | ||
ExpiresByType application/x-shockwave-flash "access 1 month" | ||
ExpiresByType image/x-icon "access 1 year" | ||
ExpiresDefault "access 1 month" | ||
</IfModule> | ||
<IfModule mod_headers.c> | ||
<filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$"> | ||
Header set Cache-Control "max-age=2678400, public" | ||
</filesmatch> | ||
Comment on lines
+59
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the above comment regarding image caching There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, please correct if I am wrong, but for files with endings |
||
<filesmatch "\.(pdf)$"> | ||
Header set Cache-Control "max-age=86400, public" | ||
</filesmatch> | ||
<filesmatch "\.(js)$"> | ||
Header set Cache-Control "max-age=2678400, private" | ||
</filesmatch> | ||
</IfModule> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this will, by default, affect HTML caching. I'll have to check that later...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It affects the expiration time for all documents if not specified by
ExpiresByType
(see Apache Module mod_expires#ExpiresDefault)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, we have to check how this affects the dynanic content in different browsers. If a browser caches the movie index page for a month without revalidatung it, that wouldn't be good.