Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Setting header expiration for files ?

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
10 posts • Page 1 of 1
Spheerys
Posts: 225
Joined: Tue Dec 29, 2015 12:36 pm

Os: Debian 7x
Web: apache + nginx
Setting header expiration for files ?
  • Quote

Post by Spheerys » Mon Jun 03, 2019 1:17 pm

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 :

Code: Select all

<FilesMatch "\.(?i:css|js)$">
  <IfModule mod_headers.c>
    Header set Cache-Control "max-age=0, public, must-revalidate"
  </IfModule>
</FilesMatch>
... but nothing change.
The headers module is correctly set :

Code: Select all

 # a2enmod headers
Module headers already enabled
Do you know where the problem come from, or what I am doing wrong ?

Thanks !

My configuration is Debian 9 with Nginx+Apache.
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: Setting header expiration for files ?
  • Quote

Post by grayfolk » Mon Jun 03, 2019 2:00 pm

You should setup headers in nginx config, not in apache.
Top

Spheerys
Posts: 225
Joined: Tue Dec 29, 2015 12:36 pm

Os: Debian 7x
Web: apache + nginx
Re: Setting header expiration for files ?
  • Quote

Post by Spheerys » Mon Jun 03, 2019 2:23 pm

OK but which file to edit ?
Top

Spheerys
Posts: 225
Joined: Tue Dec 29, 2015 12:36 pm

Os: Debian 7x
Web: apache + nginx
Re: Setting header expiration for files ?
  • Quote

Post by Spheerys » Tue Jun 04, 2019 11:50 am

On VestaCp Nginx's config, I have found this line :

Code: Select all

    # File cache settings
    open_file_cache          max=10000 inactive=30s;
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
Top

Spheerys
Posts: 225
Joined: Tue Dec 29, 2015 12:36 pm

Os: Debian 7x
Web: apache + nginx
Re: Setting header expiration for files ?
  • Quote

Post by Spheerys » Thu Jun 06, 2019 3:06 pm

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
It's enough for me, but if someone know how to make this change definitive, it could be usefull :)
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: Setting header expiration for files ?
  • Quote

Post by grayfolk » Thu Jun 06, 2019 4:16 pm

Spheerys wrote: ↑
Thu Jun 06, 2019 3:06 pm

remove "css|" (or all other filetypes) on the line "location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico...."
Good way for development, very bad for production sites.
Top

AlektroNik
Posts: 5
Joined: Wed Jun 03, 2020 4:47 pm

Os: Ubuntu 17x
Web: apache + nginx
Re: Setting header expiration for files ?
  • Quote

Post by AlektroNik » Wed Jun 03, 2020 5:06 pm

grayfolk wrote: ↑
Mon Jun 03, 2019 2:00 pm
You should setup headers in nginx config, not in apache.
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?
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: Setting header expiration for files ?
  • Quote

Post by grayfolk » Wed Jun 03, 2020 5:13 pm

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.
This is best way. Because, what reason to install nginx over apache?
If you dont have nginx - use .htaccess.
Top

AlektroNik
Posts: 5
Joined: Wed Jun 03, 2020 4:47 pm

Os: Ubuntu 17x
Web: apache + nginx
Re: Setting header expiration for files ?
  • Quote

Post by AlektroNik » Wed Jun 03, 2020 5:37 pm

grayfolk wrote: ↑
Wed Jun 03, 2020 5:13 pm
what reason to install nginx over apache?
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 :)
grayfolk wrote: ↑
Wed Jun 03, 2020 5:13 pm
If you dont have nginx - use .htaccess.
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.
Top

grayfolk
Support team
Posts: 1111
Joined: Tue Jul 30, 2013 10:18 pm
Contact:
Contact grayfolk
Website Facebook Skype Twitter

Os: CentOS 6x
Web: nginx + php-fpm
Re: Setting header expiration for files ?
  • Quote

Post by grayfolk » Wed Jun 03, 2020 6:00 pm

AlektroNik wrote: ↑
Wed Jun 03, 2020 5:37 pm

NGINX is faster gives the statics :)
Right! And this is reason to use it for serve static files.
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 :)
May be can - i dont understand, but in this case we lost nginx speed )
Top


Post Reply
  • Print view

10 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password