mod-expires

Changes in htaccess Expires header not reflecting in browser

半腔热情 提交于 2019-12-10 12:22:38
问题 I have set all JS on my site to cache for one week. However, there are specific files that I need to be refreshed at a higher frequency. Hence I have used FilesMatch to effect the exception in my .htaccess file: <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 month" # CSS ExpiresByType text/css "access plus 1 year" # Data interchange ExpiresByType application/json "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType text/xml

how to use mod_headers and mod_expires to cache

前提是你 提交于 2019-12-03 02:31:06
问题 I want to cache images and other files on my site, so what I did is made sure mod_headers and mod_expires with :- /usr/sbin/httpd -l then edited .htaccess to be:- ExpiresActive On ExpiresDefault A0 # Set up caching on media files for 1 year (forever?) <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$"> ExpiresDefault A29030400 Header append Cache-Control "public" </FilesMatch> # Set up caching on media files for 1 week <FilesMatch "\.(gif|jpg|jpeg|png|swf)$"> ExpiresDefault A604800

Cache Expire Control with Last Modification

帅比萌擦擦* 提交于 2019-12-02 18:21:56
In Apache's mod_expires module, there is the Expires directive with two base time periods, access , and modification . ExpiresByType text/html "access plus 30 days" understandably means that the cache will request for fresh content after 30 days. However, ExpiresByType text/html "modification plus 2 hours" doesn't make intuitive sense. How does the browser cache know that the file has been modified unless it makes a request to the server? And if it is making a call to the server, what is the use of caching this directive? It seems to me that I am not understanding some crucial part of caching.

how to use mod_headers and mod_expires to cache

我的梦境 提交于 2019-12-02 16:23:52
I want to cache images and other files on my site, so what I did is made sure mod_headers and mod_expires with :- /usr/sbin/httpd -l then edited .htaccess to be:- ExpiresActive On ExpiresDefault A0 # Set up caching on media files for 1 year (forever?) <FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$"> ExpiresDefault A29030400 Header append Cache-Control "public" </FilesMatch> # Set up caching on media files for 1 week <FilesMatch "\.(gif|jpg|jpeg|png|swf)$"> ExpiresDefault A604800 Header append Cache-Control "public" </FilesMatch> # Set up 2 Hour caching on commonly updated files

Add Expires Headers for Specific Images

自作多情 提交于 2019-12-01 16:36:56
All of the expires headers articles I've looked at give more or less the following solution: ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 ExpiresByType image/jpg A2592000 ExpiresByType image/jpeg A2592000 But it doesn't make sense to me because I know which of my images are going to change and which aren't, so I want to be able to add specific expiration dates to specific image files. How would I go about this? You can use a FilesMatch , eg. <FilesMatch "\.(js|css)$"> ExpiresActive on ExpiresDefault "access plus 1 month" </FilesMatch> Or for some specific files:

Add Expires Headers for Specific Images

左心房为你撑大大i 提交于 2019-12-01 16:07:42
问题 All of the expires headers articles I've looked at give more or less the following solution: ExpiresByType image/gif A2592000 ExpiresByType image/png A2592000 ExpiresByType image/jpg A2592000 ExpiresByType image/jpeg A2592000 But it doesn't make sense to me because I know which of my images are going to change and which aren't, so I want to be able to add specific expiration dates to specific image files. How would I go about this? 回答1: You can use a FilesMatch , eg. <FilesMatch "\.(js|css)$"

Add expires header without mod_expires?

徘徊边缘 提交于 2019-12-01 04:20:50
I know that I can add expires header using mod_expires. However, what can I do if the Apache server doesn't have mod_expires installed and I don't want to route the access to the files through a scripting language like PHP? You could use mod_header to set the header field manually: Header set Expires "..." But since Expires requires an absolute time , use Cache-Control ’s max-age parameter for times relative to the access time: Header merge Cache-Control max-age=3600 This should tell the browser to refresh the page on subsequent visits. The expires date just has to be in the past... you could

Add expires header without mod_expires?

心不动则不痛 提交于 2019-12-01 01:16:05
问题 I know that I can add expires header using mod_expires. However, what can I do if the Apache server doesn't have mod_expires installed and I don't want to route the access to the files through a scripting language like PHP? 回答1: You could use mod_header to set the header field manually: Header set Expires "..." But since Expires requires an absolute time, use Cache-Control’s max-age parameter for times relative to the access time: Header merge Cache-Control max-age=3600 回答2: This should tell

How to check mod_headers and mod_expires modules enabled in apache

北慕城南 提交于 2019-11-30 03:44:35
I want to check whether mod_headers and mod_expires modules enabled or not in my server Is there a way available to list apache enabled/disabled modules using some php function just like we list php information with phpinfo(); function? speeves On Debian: user@machine:~$ /usr/sbin/apache2 -l Most GNU/Linux distros: user@machine:~$ /usr/sbin/httpd -l Ubuntu: user@machine:~$ ls /etc/apache2/mods-enabled On Mac OSX: user@mymac:~$ httpd -l On Win 7 (64-bit): C:\Users\myuser>"\Program Files (x86)\Apache Software Foundation\Apache2.2\bin\httpd.exe" -l Try these commands from a terminal window in all

How to check mod_headers and mod_expires modules enabled in apache

独自空忆成欢 提交于 2019-11-29 00:45:06
问题 I want to check whether mod_headers and mod_expires modules enabled or not in my server Is there a way available to list apache enabled/disabled modules using some php function just like we list php information with phpinfo(); function? 回答1: On Debian: user@machine:~$ /usr/sbin/apache2 -l Most GNU/Linux distros: user@machine:~$ /usr/sbin/httpd -l Ubuntu: user@machine:~$ ls /etc/apache2/mods-enabled On Mac OSX: user@mymac:~$ httpd -l On Win 7 (64-bit): C:\Users\myuser>"\Program Files (x86)