I am using Gtmetrix to test my page load time. I enabled gzip compression on my site by adding code to .htaccess
.htaccess code:
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.gzip.
but still Gtmetrix showing the below warning
Enable compression for the following resources to reduce their transfer size by 687.5KiB (72% reduction).
Compressing http://www.hengleasing.com/wp-content/cache/autoptimize/js/autoptimize_bad2eb0827122f50acbfa0d977d7269a.js could save 526.3KiB (72% reduction).
you could as a workaround disable "serve as static files" in autoptimize?
Related
I'm using lottiefiles and want to activate json compression to improve my gtmetrix score... How can I activate that with litespeed web server?
Thank you in advance!
I got this answer from Lucas Rolff at wpcache slack channel:
LiteSpeed does not automatically compress json, neither as gzip or brotli, the default compressed types are:
text/*, application/x-javascript, application/xml, application/javascript, image/svg+xml,application/rss+xml
This can be modified in the LiteSpeed WebAdmin console under Configuration -> Server -> Tuning, if you want to include json (MIME type being application/json), or use the AddOutputFilterByType as in the link above in your htaccess file.
I added application/json in my LiteSpeed WebAdmin console and it is working perfect!
We have updated the default compressible type, MIME type application/json is in the default list now for new installation.
I am using Gtmetrix to test my page load time.
I enabled gzip compression on my site by adding code to .htaccess
.htaccess code:
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
but still Gtmetrix showing the below warning
Compressing http://s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js could save 453.6KiB (71% reduction). This is an external js file. How can I compress this?
Since browser requests for that file do not pass through your web server but rather go directly to s3.amazonaws.com, the short answer is: you can't.
However, you could download the file and put it on your web server and change the corresponding references in your HTML to load it from your site instead of from s3.amazonaws.com.
There is no reason why the file is not available in compressed format from Mailchimp but since they have not done so, you will need to serve it from your webserver to achieve compression.
I know in Apache One adds
RewriteEngine On
RewriteRule !(\.ico\.gif|\.png|\.jpe?g|\.css|\.js|\.php|\.eot|\.svg|\.ttf|\.woff|\.otf|^public/.*)$ index.php [nocase,last]
but How I do with Django, these rules
So, you are serving static files in Django dev server?
In settings.py I think you need:
if DEBUG:
import mimetypes
mimetypes.add_type("application/font-woff", ".woff", True)
...from info given in these questions on SO:
Resource interpreted as Font but transferred with MIME type application/x-font-woff
Django development server and MIME types
I've coded my website locally on the root of the server (WAMP running Apache 2.4.2) and i was setting the source for images and other resources with that in mind, so for instance an image called example.png would have "src=/img/example.png". Now i've moved the project to a subfolder, and the images won't load because their link is broken. I do not want to have to set the new source for each image on the html so i was hoping there would be another way to fix the links using mod_rewrite.
To demonstrate:
I want a request for
http://localhost/img/logo.gif
to go to
http://localhost/newdir/img/logo.gif
Thanks in advance!
This should do:
RewriteEngine on
RewriteRule !^newdir/ newdir%{REQUEST_URI}
See this post for more info regarding your problem:
https://stackoverflow.com/a/1612329/971459
Carefull to uncomment the following line in your httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
Having the following file structure:
-www
-newfolder
-img
-header.png
-.htaccess
When I access:
localhost/img/header.png I see the image
Can I do this through javascript or modifying the HTTP header?
http://www.example.com/downloads/*
Any files coming out of this should not be auto-download, instead, display on browser. Can I overwrite the rules set by the browser? Can I also set this limit to just this particular sub url?
Thank you.
Thanks.
What type of file are you working with?
This is used through the HTTP header. If the mime type is a certain type, the browser will decide whether to download or display it. You can also force downloading. The file type will help.
For text files, set the content-type to text/plain. For JPEGs, set it to image/jpeg, and for PNGs set it to image/png. This should overwrite any attachment values Django is setting.
You want to use the Content-Disposition header for this. It should any haggling over content-type.
http://www.ietf.org/rfc/rfc2183.txt
The default document type is declared under your server settings, not in how you link to the file. If you are under Apache try looking in httpd.conf for
DefaultType text/plain
If it says something different that may be your problem. text/plain should set all unknowns to download and be viewed in the browser as text.
EDIT:
I don't know any way of modifying this behavior through javascript as it has to be in the header of the file being downloaded.