Set individual image cache/expire date
I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )
In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
This is ready and working as expected.
My problem is, that the browser does not show the current version of the image.
As far as I can tell, Magento sets the image expiration per default as "access plus 1 month"
in the .htaccess
file in the Magento root directory.
This is ok for all images except the one I mentioned.
What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
I would be fine with a solution, that explicitly uses the filename of my image.
htaccess
add a comment |
I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )
In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
This is ready and working as expected.
My problem is, that the browser does not show the current version of the image.
As far as I can tell, Magento sets the image expiration per default as "access plus 1 month"
in the .htaccess
file in the Magento root directory.
This is ok for all images except the one I mentioned.
What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
I would be fine with a solution, that explicitly uses the filename of my image.
htaccess
add a comment |
I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )
In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
This is ready and working as expected.
My problem is, that the browser does not show the current version of the image.
As far as I can tell, Magento sets the image expiration per default as "access plus 1 month"
in the .htaccess
file in the Magento root directory.
This is ok for all images except the one I mentioned.
What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
I would be fine with a solution, that explicitly uses the filename of my image.
htaccess
I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )
In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
This is ready and working as expected.
My problem is, that the browser does not show the current version of the image.
As far as I can tell, Magento sets the image expiration per default as "access plus 1 month"
in the .htaccess
file in the Magento root directory.
This is ok for all images except the one I mentioned.
What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
I would be fine with a solution, that explicitly uses the filename of my image.
htaccess
htaccess
edited Nov 12 '17 at 13:40
Teja Bhagavan Kollepara
2,94841847
2,94841847
asked Nov 18 '13 at 16:57
CelldwellerCelldweller
61821325
61821325
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images
This seems like the most logical solution. So, you'd end up with something like :
<FilesMatch "^(seal.jpg)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</FilesMatch>
You should be able to use any of the following for timings:
- years
- months
- weeks
- days
- hours
- minutes
- seconds
add a comment |
#THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
#THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
#PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
#IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
#APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
#THE SEAL.JPG FILE IS.
#IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
#USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
<FilesMatch "^seal.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
<FilesMatch "^seal.*.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
</IfModule>
**I am 99% certain it does not matter which comes first
**(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
**FilesMatch will take precedence.
**@Douglas answer set me on the right track,**
**but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
**What did i get wrong?**
#keywords: how to set Expires HTTP headers on a file named X.
#change the cache of one file. cache only one file. how to cache one file.
#I do not want to cache by type Web server cache one file
add a comment |
Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?
That is the code from the.htaccess
but I would like to know who I can address a specific image. e.g. I have an imageseal.jpg
. What would I need to write in the.htaccess
file in order to have a file expiration of 1 day? I doubt it is something likeExpiresByName seal.jpg
– Celldweller
Nov 19 '13 at 15:57
Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…
– MagentoMac
Nov 19 '13 at 21:50
Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html
– MagentoMac
Nov 19 '13 at 21:51
Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?
– Celldweller
Nov 20 '13 at 7:33
I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>
– MagentoMac
Nov 20 '13 at 18:41
|
show 1 more comment
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f10915%2fset-individual-image-cache-expire-date%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images
This seems like the most logical solution. So, you'd end up with something like :
<FilesMatch "^(seal.jpg)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</FilesMatch>
You should be able to use any of the following for timings:
- years
- months
- weeks
- days
- hours
- minutes
- seconds
add a comment |
The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images
This seems like the most logical solution. So, you'd end up with something like :
<FilesMatch "^(seal.jpg)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</FilesMatch>
You should be able to use any of the following for timings:
- years
- months
- weeks
- days
- hours
- minutes
- seconds
add a comment |
The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images
This seems like the most logical solution. So, you'd end up with something like :
<FilesMatch "^(seal.jpg)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</FilesMatch>
You should be able to use any of the following for timings:
- years
- months
- weeks
- days
- hours
- minutes
- seconds
The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images
This seems like the most logical solution. So, you'd end up with something like :
<FilesMatch "^(seal.jpg)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</FilesMatch>
You should be able to use any of the following for timings:
- years
- months
- weeks
- days
- hours
- minutes
- seconds
edited May 23 '17 at 12:37
Community♦
1
1
answered Mar 19 '14 at 13:40
Douglas RadburnDouglas Radburn
1,880927
1,880927
add a comment |
add a comment |
#THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
#THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
#PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
#IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
#APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
#THE SEAL.JPG FILE IS.
#IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
#USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
<FilesMatch "^seal.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
<FilesMatch "^seal.*.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
</IfModule>
**I am 99% certain it does not matter which comes first
**(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
**FilesMatch will take precedence.
**@Douglas answer set me on the right track,**
**but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
**What did i get wrong?**
#keywords: how to set Expires HTTP headers on a file named X.
#change the cache of one file. cache only one file. how to cache one file.
#I do not want to cache by type Web server cache one file
add a comment |
#THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
#THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
#PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
#IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
#APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
#THE SEAL.JPG FILE IS.
#IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
#USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
<FilesMatch "^seal.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
<FilesMatch "^seal.*.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
</IfModule>
**I am 99% certain it does not matter which comes first
**(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
**FilesMatch will take precedence.
**@Douglas answer set me on the right track,**
**but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
**What did i get wrong?**
#keywords: how to set Expires HTTP headers on a file named X.
#change the cache of one file. cache only one file. how to cache one file.
#I do not want to cache by type Web server cache one file
add a comment |
#THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
#THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
#PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
#IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
#APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
#THE SEAL.JPG FILE IS.
#IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
#USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
<FilesMatch "^seal.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
<FilesMatch "^seal.*.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
</IfModule>
**I am 99% certain it does not matter which comes first
**(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
**FilesMatch will take precedence.
**@Douglas answer set me on the right track,**
**but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
**What did i get wrong?**
#keywords: how to set Expires HTTP headers on a file named X.
#change the cache of one file. cache only one file. how to cache one file.
#I do not want to cache by type Web server cache one file
#THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
#THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
#PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
#IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
#APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
#THE SEAL.JPG FILE IS.
#IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
#USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
<FilesMatch "^seal.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
<FilesMatch "^seal.*.jpg$">
ExpiresByType image/jpeg "access plus 12 hours"
</FilesMatch>
</IfModule>
**I am 99% certain it does not matter which comes first
**(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
**FilesMatch will take precedence.
**@Douglas answer set me on the right track,**
**but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
**What did i get wrong?**
#keywords: how to set Expires HTTP headers on a file named X.
#change the cache of one file. cache only one file. how to cache one file.
#I do not want to cache by type Web server cache one file
edited 1 hour ago
answered Oct 24 '17 at 2:18
somebadhatsomebadhat
114
114
add a comment |
add a comment |
Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?
That is the code from the.htaccess
but I would like to know who I can address a specific image. e.g. I have an imageseal.jpg
. What would I need to write in the.htaccess
file in order to have a file expiration of 1 day? I doubt it is something likeExpiresByName seal.jpg
– Celldweller
Nov 19 '13 at 15:57
Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…
– MagentoMac
Nov 19 '13 at 21:50
Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html
– MagentoMac
Nov 19 '13 at 21:51
Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?
– Celldweller
Nov 20 '13 at 7:33
I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>
– MagentoMac
Nov 20 '13 at 18:41
|
show 1 more comment
Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?
That is the code from the.htaccess
but I would like to know who I can address a specific image. e.g. I have an imageseal.jpg
. What would I need to write in the.htaccess
file in order to have a file expiration of 1 day? I doubt it is something likeExpiresByName seal.jpg
– Celldweller
Nov 19 '13 at 15:57
Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…
– MagentoMac
Nov 19 '13 at 21:50
Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html
– MagentoMac
Nov 19 '13 at 21:51
Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?
– Celldweller
Nov 20 '13 at 7:33
I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>
– MagentoMac
Nov 20 '13 at 18:41
|
show 1 more comment
Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?
Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?
answered Nov 18 '13 at 23:04
MagentoMacMagentoMac
62441333
62441333
That is the code from the.htaccess
but I would like to know who I can address a specific image. e.g. I have an imageseal.jpg
. What would I need to write in the.htaccess
file in order to have a file expiration of 1 day? I doubt it is something likeExpiresByName seal.jpg
– Celldweller
Nov 19 '13 at 15:57
Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…
– MagentoMac
Nov 19 '13 at 21:50
Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html
– MagentoMac
Nov 19 '13 at 21:51
Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?
– Celldweller
Nov 20 '13 at 7:33
I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>
– MagentoMac
Nov 20 '13 at 18:41
|
show 1 more comment
That is the code from the.htaccess
but I would like to know who I can address a specific image. e.g. I have an imageseal.jpg
. What would I need to write in the.htaccess
file in order to have a file expiration of 1 day? I doubt it is something likeExpiresByName seal.jpg
– Celldweller
Nov 19 '13 at 15:57
Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…
– MagentoMac
Nov 19 '13 at 21:50
Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html
– MagentoMac
Nov 19 '13 at 21:51
Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?
– Celldweller
Nov 20 '13 at 7:33
I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>
– MagentoMac
Nov 20 '13 at 18:41
That is the code from the
.htaccess
but I would like to know who I can address a specific image. e.g. I have an image seal.jpg
. What would I need to write in the .htaccess
file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg
– Celldweller
Nov 19 '13 at 15:57
That is the code from the
.htaccess
but I would like to know who I can address a specific image. e.g. I have an image seal.jpg
. What would I need to write in the .htaccess
file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg
– Celldweller
Nov 19 '13 at 15:57
Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…
– MagentoMac
Nov 19 '13 at 21:50
Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…
– MagentoMac
Nov 19 '13 at 21:50
Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html
– MagentoMac
Nov 19 '13 at 21:51
Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html
– MagentoMac
Nov 19 '13 at 21:51
Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?
– Celldweller
Nov 20 '13 at 7:33
Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?
– Celldweller
Nov 20 '13 at 7:33
I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>
– MagentoMac
Nov 20 '13 at 18:41
I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>
– MagentoMac
Nov 20 '13 at 18:41
|
show 1 more comment
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f10915%2fset-individual-image-cache-expire-date%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown