We have our winners! Thank you for reading and voting [ Dismiss ]
Home » Forum » Bug Report and Feature Requests

Forum: Bug Report and Feature Requests

incorrect server response on res/js.php

Gauthier 🚫

Looks like a server issue:
the etag request and response are the same, yet your server send a 200 instead of a 304.

The vary on User-Agent make little sense unless you want to overwhelm the server cache.

That said, when you change the js, you should increment the version in the filename and allow caching in-definitively for that kind of file...

Do you plan to deliver different js code for different users?

HTTP Request
------------

GET /res/js.php?s=dc.min.401.js HTTP/2
Host: storiesonline.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
DNT: 1
Connection: keep-alive
Cookie: sa_pref=*; drk=0; cookie=*; salt=*; lvt=*; stwd=*; solcore=*; sbs=; x=*; selSt=*
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
If-Modified-Since: Fri, 14 Jun 2024 07:55:17 GMT
If-None-Match: "12ff-19015be6288-gzip"
Priority: u=1

HTTP Response
--------------

HTTP/2 200
cache-control:
pragma:
expires:
x-frame-options: SAMEORIGIN
last-modified: Fri, 14 Jun 2024 07:55:17 GMT
etag: "12ff-19015be6288-gzip"
vary: Accept-Encoding,User-Agent
content-encoding: gzip
x-xss-protection: 1; mode=block
content-length: 1879
content-type: application/javascript
date: Mon, 24 Jun 2024 15:37:55 GMT
server: Apache
X-Firefox-Spdy: h2

var req,tags=[],.....

Lazeez Jiddan (Webmaster)

@Gauthier

the etag request and response are the same, yet your server send a 200 instead of a 304.

Why? It's not a redirect. js.php sends the js code via readfile().

Do you plan to deliver different js code for different users?

No, this is about having one JS repository for the admin side and the user side, despite both being separate code trees and different domains.

Replies:   Gauthier  Gauthier
Gauthier 🚫
Updated:

@Lazeez Jiddan (Webmaster)

It's not a redirect

304 means not modified, it's telling the client to rely on it's cache, which we know he has because he sent the etag.

via readfile()

Never use readfile with php. The optimal way is to use to rely on the syscall sendfile in apache/nginx you do that with the header X-Sendfile with mod_xsendfile and let apache handle the file IO.
That's a 140% IO performance improvement, maybe more in your use case.

I think that since X-SendFile let Apache handle headers, it will lead to the correct 304 instead of 200.

Using a cacheless php to send js is an heavy price to pay doubling the process pool memory requirement on the servers because each html page request means two php process.

If the domain are different and the js are versioned, why not allow caching? There is no risk of mix-up. Maybe add cache-control:private.

If you plan to use both version on the same domain, you need to clear the cache when switching from regular user to admin users. But that would be a real pain to handle for the admins.

Gauthier 🚫
Updated:

@Lazeez Jiddan (Webmaster)

No, this is about having one JS repository for the admin side and the user side, despite both being separate code trees and different domains.

You know, you could also get the same result with mod_rewrite using a RewriteCond and Redirect or RewriteRule.
retargeting /js/ to /res/js/ or /res/admin-js/ depending on the domain.
You already have a redirect in place for /js/.

Replies:   Gauthier
Gauthier 🚫

@Gauthier

Thanks for the correction, it's still not an X-SendFile, but the cache on js.php now works.
The server slow down I experienced yesterday which prompted this bug report are gone. Not sure if it's related.

Lazeez Jiddan (Webmaster)

@Gauthier

Thanks for the correction, it's still not an X-SendFile, but the cache on js.php now works.
The server slow down I experienced yesterday which prompted this bug report are gone. Not sure if it's related.

The change that I made was to add the cache control: private header, and the expires header.

Everything else is exactly the same.

The problem that I have with x_sendfile for now is that it's not supported on the Mac for some reason, and I need to find a way to install it in order to write the proper code.

Back to Top

Close
 

WARNING! ADULT CONTENT...

Storiesonline is for adult entertainment only. By accessing this site you declare that you are of legal age and that you agree with our Terms of Service and Privacy Policy.


Log In