logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: 302 redirects when resources exist, when page reactivated
Author
SendSimply



Joined: 25 Mar 2023
Posts: 3
Location: England

PostPosted: Sat 25 Mar '23 17:52    Post subject: 302 redirects when resources exist, when page reactivated Reply with quote

Hello,

When I navigate to any of the pages on our website, the CSS loads just fine - the server logs show a 200 on the CSS file. However, if I switch to a different tab and come back to the tab a few hours later, sometimes the page will have refreshed but without the CSS so it looks terrible, and the server logs show 302 on the CSS file. After an F5, it loads fine. I've used Apache for years and have never seen this issue before.

Using Apache/2.4.38 (Debian)
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 312
Location: UK

PostPosted: Sun 26 Mar '23 21:27    Post subject: Reply with quote

I'm somewhat confused.

A 200 response logged by Apache for your CSS file suggests it's content was served locally, whereas a 302 response is a redirect to a remote URL for the CSS file, presumably on a different server. Are all CSS files served locally?

Whichever, I suggest you look at the browser traffic using Developer Tools (Firefox/Chrome), and check for any Cache-Control or Expires headers returned by the web server(s) for the various CSS files. This should give you a clue as to what's going on, particularly if there may be intermediate proxies between your web server and clients.

Does you web server have any specific configuration settings for browser caching of static content, e.g.

Code:
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
  Header set Cache-Control "max-age=84600, public"
</filesMatch>
Back to top
SendSimply



Joined: 25 Mar 2023
Posts: 3
Location: England

PostPosted: Mon 27 Mar '23 9:29    Post subject: Reply with quote

All CSS files are served locally - it may be thinking it's a remote URL because I specify the full domain in the ErrorDocument directive;

Code:
ErrorDocument 404 https://ourdomain.co.uk/


Other than that, we're using pretty much the default apache2.conf - so no cache-control changes.

I know that there are no proxies between the web server and my browser, at least.

I'll have a closer look at the headers that the browser receives when it happens
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7294
Location: Germany, Next to Hamburg

PostPosted: Tue 28 Mar '23 8:41    Post subject: Reply with quote

SendSimply wrote:

Code:
ErrorDocument 404 https://ourdomain.co.uk/



I would at least append a query string like "?404" to be sure for debugging.
Back to top
SendSimply



Joined: 25 Mar 2023
Posts: 3
Location: England

PostPosted: Wed 29 Mar '23 22:32    Post subject: Reply with quote

The issue seems to have gone away after adding the following directive as a shot in the dark:

Code:

<FilesMatch '\.php'>
    Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
</FilesMatch>


I would assume that the issue stems from Chrome caching PHP-served page content at times now rather than pulling the page fresh every time - though the content still contains the CSS link as per the console error when it sees the 302 (404) text/html content where a CSS file should be... I think it might be a Chrome bug. I'd much rather the HTML output of php files wasn't cached anyway so I think the directive is there to stay.
Back to top


Reply to topic   Topic: 302 redirects when resources exist, when page reactivated View previous topic :: View next topic
Post new topic   Forum Index -> Apache