We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Setting header expiration for files ?
Setting header expiration for files ?
Hi,
I'm a web integrator and I'm using VestaCP to host my websites.
When I'm changing a CSS file with FTP or SSH, the new file is not reload immediatly, but after a while.
It's very anoying during the integration time :)
I thaught it could be caused because of nginx/apache header expiration setting but I'm not sure 100%
After web research, I have set theses lines on my local .htaccess file :
... but nothing change.
The headers module is correctly set :
Do you know where the problem come from, or what I am doing wrong ?
Thanks !
My configuration is Debian 9 with Nginx+Apache.
I'm a web integrator and I'm using VestaCP to host my websites.
When I'm changing a CSS file with FTP or SSH, the new file is not reload immediatly, but after a while.
It's very anoying during the integration time :)
I thaught it could be caused because of nginx/apache header expiration setting but I'm not sure 100%
After web research, I have set theses lines on my local .htaccess file :
Code: Select all
<FilesMatch "\.(?i:css|js)$">
<IfModule mod_headers.c>
Header set Cache-Control "max-age=0, public, must-revalidate"
</IfModule>
</FilesMatch>
The headers module is correctly set :
Code: Select all
# a2enmod headers
Module headers already enabled
Thanks !
My configuration is Debian 9 with Nginx+Apache.
-
- Support team
- Posts: 1111
- Joined: Tue Jul 30, 2013 10:18 pm
- Contact:
- Os: CentOS 6x
- Web: nginx + php-fpm
Re: Setting header expiration for files ?
You should setup headers in nginx config, not in apache.
Re: Setting header expiration for files ?
OK but which file to edit ?
Re: Setting header expiration for files ?
On VestaCp Nginx's config, I have found this line :
I suppose a value to 2s will solve my issue but I wonder if there is not a website specific setting instead of a server setting which overload the whole server load
Code: Select all
# File cache settings
open_file_cache max=10000 inactive=30s;
Re: Setting header expiration for files ?
I have found the way to edit only a particular website, but this modification will disappear after a v-rebuild-web-domain :
- edit the file /home/USER/conf/web/domain.tld.nginx.conf
- remove "css|" (or all other filetypes) on the line "location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico...."
- service nginx restart
-
- Posts: 5
- Joined: Wed Jun 03, 2020 4:47 pm
- Os: Ubuntu 17x
- Web: apache + nginx
Re: Setting header expiration for files ?
Hi.
And there is the option of using .htaccess?
If different sites need to use different settings what to do?
Use templates with nginx is not convenient, it is necessary for each site template to create.
Maybe I can use .user.ini?
-
- Support team
- Posts: 1111
- Joined: Tue Jul 30, 2013 10:18 pm
- Contact:
- Os: CentOS 6x
- Web: nginx + php-fpm
Re: Setting header expiration for files ?
This is best way. Because, what reason to install nginx over apache?AlektroNik wrote: ↑Wed Jun 03, 2020 5:06 pm
Use templates with nginx is not convenient, it is necessary for each site template to create.
If you dont have nginx - use .htaccess.
-
- Posts: 5
- Joined: Wed Jun 03, 2020 4:47 pm
- Os: Ubuntu 17x
- Web: apache + nginx
Re: Setting header expiration for files ?
NGINX is faster gives the statics :)
I can't believe NGINX can not proxy headers from .htaccess. I would like to believe that I just don't know how to cook it :)
If indeed the only more or less acceptable option is to use templates with NGINX, then probably will consider using only Apache. :(
Thank you very much.
-
- Support team
- Posts: 1111
- Joined: Tue Jul 30, 2013 10:18 pm
- Contact:
- Os: CentOS 6x
- Web: nginx + php-fpm
Re: Setting header expiration for files ?
Right! And this is reason to use it for serve static files.
May be can - i dont understand, but in this case we lost nginx speed )AlektroNik wrote: ↑Wed Jun 03, 2020 5:37 pm
I can't believe NGINX can not proxy headers from .htaccess. I would like to believe that I just don't know how to cook it :)