Jump to content
  • 0

Cannot configure .htaccess "Expires" on Prestashop Cloud


JPresta.com

Question

Default expires duration on Prestashop Cloud for static files is 1 day which is very short. I want to set it to 1 month but when I add this (taken from Tools.php class) into .htaccess file I get HTTP 500 error:

<IfModule mod_expires.c>
	ExpiresActive On
	ExpiresByType image/gif "access plus 1 month"
	ExpiresByType image/jpeg "access plus 1 month"
	ExpiresByType image/png "access plus 1 month"
	ExpiresByType text/css "access plus 1 week"
	ExpiresByType text/javascript "access plus 1 week"
	ExpiresByType application/javascript "access plus 1 week"
	ExpiresByType application/x-javascript "access plus 1 week"
	ExpiresByType image/x-icon "access plus 1 year"
	ExpiresByType image/svg+xml "access plus 1 year"
	ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
	ExpiresByType application/font-woff "access plus 1 year"
	ExpiresByType application/x-font-woff "access plus 1 year"
	ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
	ExpiresByType font/opentype "access plus 1 year"
	ExpiresByType font/ttf "access plus 1 year"
	ExpiresByType font/otf "access plus 1 year"
	ExpiresByType application/x-font-ttf "access plus 1 year"
	ExpiresByType application/x-font-otf "access plus 1 year"
</IfModule>

<IfModule mod_headers.c>
	Header unset Etag
</IfModule>

FileETag none

<IfModule mod_deflate.c>
	<IfModule mod_filter.c>
		AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript application/x-javascript
	</IfModule>
</IfModule>

Any idea on how to debug or fix this?

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

Response from Prestashop support:

 

 

Hello,We can't help you to edit your .htaccess with a custom configuration.This is a support to help you to use and configure PrestaShop.
Thanks for using our solution, we keep at your disposal, Regards

Great, thank you for this support!

 

Come on guys! This

<IfModule mod_expires.c>
ExpiresActive On
</IfModule>

Should not give me an HTTP 500!

Link to comment
Share on other sites

  • 0

Did you read my topic ? 

Yes I did but actually it is possible to modify .htaccess file since it is editable through FTP.

 

Yes it should if the modul mod_expires is not activated on the server. And surely it is not and the reason why you are receiving an 500 HTP.error.

No it should not. That's the purpose of the <IfModule> directive.

Link to comment
Share on other sites

  • 0

<ifModule> says only: if the module xxx is.... than do yyyy....

 

If mod_expire is not installed/enabled or configured on the server you will receive a 500 HTTP error code.

 

You already tried to activate the module with: ExpiresActive On. If this line does not activate the module and you are receiving again a 500 error than the module is definitely not enabled on their servers.

Edited by selectshop.at (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 0

Hi Joe,

 

you may use mod_headers instead of mod_expires. But don't use it with a set expires parameter, take instead

set Cache-Control "max-age=seconds" 

The following is a working solution for one month expiration in the cloud and doesn't cause a 500:

<IfModule mod_headers.c>
  <FilesMatch "\.(ico|ttf|php|tpl|otf|jpg|jpeg|png|gif|js|css|xml)$">
    Header set Cache-Control "max-age=2592000"
    Header set Cache-Control "public"
  </FilesMatch>
</IfModule>

Feel free to modify the FilesMatch. :)

 

Regards,

eleazar

Edited by eleazar (see edit history)
Link to comment
Share on other sites

  • 0

I did some tests. My headers are correctly added but if I have 2 lines:

Header set Cache-Control "max-age=2592000"
Header set Cache-Control "public"

Then only the last one is present (looks logical)

If I only put 

Header set Cache-Control "max-age=2592000"

The header is present but I also have the Expires one which is still set to 1 day

Cache-Control:max-age=2592000
Connection:Keep-Alive
Date:Tue, 24 Feb 2015 14:34:54 GMT
Expires:Wed, 25 Feb 2015 14:34:54 GMT
Keep-Alive:timeout=5, max=100
Server:Apache
Set-Cookie:prestashopfr1=R2804834139; path=/; expires=Tue, 24-Feb-2015 15:36:15 GMT
Vary:Accept-Encoding
Link to comment
Share on other sites

  • 0

I get these headers in response

Accept-Ranges:bytes
Cache-Control:max-age=2592000, s-maxage=2592000, public, must-revalidate, proxy-revalidate, no-transform
Connection:Keep-Alive
Content-Length:12117
Content-Type:image/jpeg
Date:Tue, 24 Feb 2015 18:38:00 GMT
Expires:Wed, 25 Feb 2015 18:38:00 GMT
Keep-Alive:timeout=5, max=100
Last-Modified:Tue, 24 Feb 2015 12:13:57 GMT
Server:Apache
Set-Cookie:prestashopfr1=R2804834139; path=/; expires=Tue, 24-Feb-2015 19:54:36 GMT

Anyway, according to this post 'Cache-control'  overrides 'Expires' header so it should be good :-)

 

I changed to "max-age=2592000, private" For more details http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

Edited by pagecache (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...