Answer the question
In order to leave comments, you need to log in
Am I doing the right thing with loading JS|CSS via php?
Initially, my site structure consists of two root directories, one of which stores files that are not accessible to the user directly from the web browser, i.e. core files and files available through the web, i.e. public files.
At the moment, I store my CSS/JS in the public directory and load them using standard methods. In order to reduce the division of directories and information available to the user in public, I want to transfer the whole thing to the core directory and from there to cling to them using the php entry point.
But reading articles on the Internet on this method, I additionally found out both the pros and cons.
Pluses are:
1. Inaccessibility of files directly.
2. Loading only those files that are needed at the moment.
3. Reducing HTTP requests.
The cons are:
1. Lack of caching.
This is the only minus that strained me with the fact that if a user visits 10 different pages, then the same thing will be loaded 10 times for him.
I poked around and found that the entry point can also be cached. And found the relevant HTTP headers, for example:
Cache-Control: no-transform,public,max-age=300,s-maxage=900
. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question