I am using the assetic manager to serve my css and js files however the browser is loading them on every page request instead of caching them locally. I have checked the Last-Modified response header when fetching the css/js file and it is the same time as the request, which I assume is why it is returning the full file with a 200 response instead of a 304.
I am using the production environment with the following config:
assetic:
debug: "%kernel.debug%"
use_controller: false
filters:
cssrewrite: ~
lessphp:
apply_to: "\.less$"
formatter: "compressed"
preserve_comments: false
How can I get Symfony to send the Last-Modified time of the created assetic file so that it is cached in the browser?
Assetic or Symfony do not set any Last-Modified cache headers for any asset files. Assetic just generates any needed css/js files and modifies any link that uses them, but then they are served by the web server as any other static file. You should look into your web server configuration to find out how to set Last-Modified headers for static files.
Related
Is there a way to change the endpoint that static JS files get served up from in Bokeh?
I have a number of bokeh dashboards that are accessed from behind a load balancer
Any request to https://myloadbalancer/{dashboard_name} is sent to the load balancer
The loadbalancer then routes the requests to the correct dashboard server based on the value of /{dashboard_name}
For any given dashboard, bokeh then attempts to access static javascript via https://myloadbalancer/static
For this to work, I need to create a new bokeh server just to serve up static files and then configure the loadbalancer to route requests to https://myloadbalancer/static to the new server
This approach is fine, until you start getting different javascript dependencies in the different dashboards
Does anyone know of a way to change the /static path of a bokeh dashboard. So that for example it reads static files from https://myloadbalancer/{dashboard_name}/static?
You can run your bokeh serve command with the option --prefix <base_path>. This will put <base_path> behind every resource requested to the Bokeh (Torando) web server, this applies also for /static resources.
Here you can find the official Bokeh documentation page.
Kind regards
i have big json file that i load in the index.js On page load (javascript) file which leads to increase in the time of loading the page.
What should i use to reduce this so that the page loads fast?
You need to enable gzip on your server level, In configuration compressableMimeType you can specify which type of data to be compressed.
<Connector port="8090" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444"
compression="on" compressableMimeType="text/html,
text/xml,text/plain,text/javascript,text/css,application/json" />
You can visit http://viralpatel.net/blogs/enable-gzip-compression-in-tomcat/ for configuration steps
In your Apache configuration, set mod_deflate parameters. See here for complete doc
Depending on your configuration, apache config could be located:
Windows C:\Program Files\Apache Group\Apache2\conf\httpd.conf
Linux: /etc/httpd/conf/httpd.conf
Version control repositories started to serve raw files as text/plain and to add the header content-type-options: nosniff so they can't be used as static hosting. I have an internal GitLab installation that I want to use to host some javascript (it would be used to access GitLab own API).
Is it possible to serve a raw file as Javascript? I'd like to turnoff the http header or change the mime-type of the serverd file.
No, it isn't possible to serve directly from the repository, since GitLab won't serve the correct mime type. If you want to do it, you probably need to use GitLab Pages.
I'm new to all things coding and have tried to use Azure to host a web app. The app is JavaScript using PHP to process MYSQL data. Everything works locally as expected. But when I try to access the app where it's hosted, I see 404 (Not Found) errors on all of my calls to .php files.
I'm using jQuery's getJSON to get data:
$.getJSON('bin/myFile.php', function(data) {
// Process data
})
Then in the browser console I see:
GET https://mysite.azurewebsites.net/bin/myFile.php 404 (Not Found)
But, if I move that file to the root directory and drop the bin/ from my call, it works perfectly. All other calls to files in folders work fine (images, scripts, styles), only the php files in the bin folder return this error.
Anyone know why?
Answer from comments:
Try renaming your bin folder. That is normally where binary files are placed in a windows web app environment, so it's possible the Azure server is configured to not serve any files from that location –
Rory McCrossan
Sep 26 '17 at 16:22
In my development.rb I have
config.assets.debug = true
config.assets.compress = false
However my assets are being served in single files"
images/application.js
javascripts/application.css
I have deleted the cache files from tmp/cache & restarted the server but assets are still served in a single file (not compressed by the way).
I'm running Rails 3.2.13.
Has anyone got any ideas?