I have several javascript files that are not being compressed, as far as I can tell via scans like Pagespeed insights and GtMetrix. I have the following code in my .htaccess file to enable compression.
<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>
I have also tried adding the following line but got no difference
mod_gzip_item_include mime ^text/javascript.*
What needs to be done?
Thanks
I am trying to add gzip compression for my SVG files but it seem not to work, here is my code:
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|svg+xml|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>
I tryed adding svg or svg+xml to mod_gzip_item_include file. But according to google pagespeed it is still not working. I also tryed to add mod_gzip_item_include mime ^image/.svg. I think the exclude all images is blocking the gzip of the SVG.
My website loading speed is much low.
My Website Link
On testing my site on google page speed tool, I came to know that by GZIP will effective to solve this issue.
I wants to know how to do gzip compression via .htaccess
I hope you already have a .htaccess file on the webroot. Then include following codes into your .htaccess file.
<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>
You can be make sure whether gzip is enabled using following steps
Open chrome browser and press F12 open chrome developer tool
Enter your web url. Once web site is loaded, you would see response header
like below screenshot if gzip is enabled. (see attached screenshot)
I have added the following to my .htaccess file
# MIME Types for WAP
AddType text/vnd.wap.wml .wml
AddType image/vnd.wap.wbmp .wbmp
AddType application/vnd.wap.wmlc .wmlc
AddType text/vnd.wap.wmlscript .wmls
AddType application/vnd.wap.wmlscriptc .wmlsc
AddType application/vnd.wap.xhtml+xml .xhtml
However the file is saved as index.php and uses the following header:
header("Content-Type: application/vnd.wap.xhtml+xml");
The file currently tries to download can anyone advise how to rectify this?
Use the XHTML MIME type in addition to the existing mappings:
AddType application/xhtml+xml .xhtml
In addition, AddHandler can be used to handle that content-type.
I've installed Koha 3.6 - as provided by Vimal Kumar on Ubuntu 10.04 LTS. This works excellently.
However, I want to access the web Staff/OPAC client via LAN, so that I can open the clients on another computer (Windows 7) in addition to accessing it on the Koha machine.
Vimal directed me to this website: http://kohageek.pbworks.com/w/page/51840331/Network%20Configuration
Here is a break down of the instructions, and what I did. This method failed, and I reverted my files back to their original content, and my Staff/OPAC clients work again now, but are still not accessible on LAN.
I've got a router for this, and I connected each computer to the router - they can see each other on the network.
1) sudo gedit /etc/hosts
Enter the IP Address and Fully Qualified Domain Name
My original file contains the following:
127.0.0.1 localhost
127.0.1.1 ansa-desktop
#The following lines are desirable for IPv6 capable hosts)
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
I replaced the top part with:
127.0.0.1 localhost
192.168.1.10 ansa-desktop
2) sudo gedit /etc/hostname
Enter the hostname of your system without domain name
My file contains the following:
ansa-desktop
I didn't make changes in this file - it look right to me.
3) In System --> Preferences -> Network Connections
Choose DHCP or Enter Static IP Number, subnet mask and gateway information
I chose the following:
IP: 192.168.1.10
Subnetmask:255.255.255.0
Gateway: 0.0.0.0 (automatically set)
4) sudo gedit /etc/koha/koha-httpd.conf
Change the IP number in OPAC and Intranet virtual host.
My original file contained the following and the IPs in bold was subsequently swapped with my selected static IP (192.168.1.10):
# Koha Apache Configuration Directives
#NameVirtualHost *
## OPAC
'<'VirtualHost 127.0.1.1:80>
ServerAdmin webmaster#koha-desktop
DocumentRoot /usr/share/koha/opac/htdocs
ServerName koha-desktop
# ServerAlias opac.mydomain.com
ScriptAlias /cgi-bin/koha/ "/usr/share/koha/opac/cgi-bin/opac/"
ScriptAlias /index.html "/usr/share/koha/opac/cgi-bin/opac/opac-main.pl"
ScriptAlias /opac-search.pl "/usr/share/koha/opac/cgi-bin/opac/opac-search.pl"
ScriptAlias /search "/usr/share/koha/opac/cgi-bin/opac/opac-search.pl"
ErrorLog /var/log/koha/koha-opac-error_log
# CustomLog /var/log/koha/koha-opac-access_log combined
# TransferLog /var/log/koha/koha-opac-access_log
SetEnv KOHA_CONF "/etc/koha/koha-conf.xml"
SetEnv PERL5LIB "/usr/share/koha/lib"
SetEnv MEMCACHED_SERVERS ""
SetEnv MEMCACHED_NAMESPACE ""
<IfModule mod_gzip.c>
mod_gzip_on yes
mod_gzip_dechunk yes
mod_gzip_keep_workfiles No
mod_gzip_can_negotiate yes
mod_gzip_update_static No
mod_gzip_temp_dir /tmp
mod_gzip_minimum_file_size 512
mod_gzip_maximum_file_size 1000000
mod_gzip_maximum_inmem_size 1000000
mod_gzip_handle_methods GET POST
mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader Content-Type:image/*
mod_gzip_item_include file \.js$
mod_gzip_item_include mime ^application/javascript$
mod_gzip_item_include mime ^application/x-javascript$
mod_gzip_item_include file \.php$
mod_gzip_item_include mime ^text/html$
mod_gzip_item_include file \.css$
mod_gzip_item_include mime ^text/css$
</IfModule>
<IfModule mod_deflate.c>
# Compress content with type html, text, and css, ...
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
DeflateCompressionLevel 9
# Properly handle old browsers that do not support compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
<IfModule mod_headers.c>
#properly handle requests coming from behind proxies
Header append Vary User-Agent
</IfModule>
</IfModule>
# Repeat this virtualhost stanza changing the following environment vars to
# create multiple OPAC interfaces with custom css and/or search limits:
# SetEnv OPAC_CSS_OVERRIDE mystyle.css
# SetEnv OPAC_SEARCH_LIMIT branch:CODE
# SetEnv OPAC_LIMIT_OVERRIDE 1
Options +FollowSymLinks
ErrorDocument 400 /cgi-bin/koha/errors/400.pl
ErrorDocument 401 /cgi-bin/koha/errors/401.pl
ErrorDocument 403 /cgi-bin/koha/errors/403.pl
ErrorDocument 404 /cgi-bin/koha/errors/404.pl
ErrorDocument 500 /cgi-bin/koha/errors/500.pl
# Rewrite Rules
RewriteEngine On
# Uncomment to turn on rewrite logging
# RewriteLog /var/log/koha/koha-opac-rewrite.log
# RewriteLogLevel 1
RewriteCond %{QUERY_STRING} (.?)(?:[A-Za-z0-9_-]+)=&(.)
RewriteRule (.+) $1?%1%2 [N,R,NE]
RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT]
RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
## Intranet
'<'VirtualHost 127.0.1.1:8080>
ServerAdmin webmaster#koha-desktop
DocumentRoot /usr/share/koha/intranet/htdocs
ServerName koha-desktop:8080
# ServerAlias intranet.mydomain.com
ScriptAlias /cgi-bin/koha/ "/usr/share/koha/intranet/cgi-bin/"
ScriptAlias /index.html "/usr/share/koha/intranet/cgi-bin/mainpage.pl"
ScriptAlias /search "/usr/share/koha/intranet/cgi-bin/search.pl"
ErrorLog /var/log/koha/koha-error_log
# TransferLog /var/log/koha/koha-access_log
SetEnv KOHA_CONF "/etc/koha/koha-conf.xml"
SetEnv PERL5LIB "/usr/share/koha/lib"
SetEnv MEMCACHED_SERVERS ""
SetEnv MEMCACHED_NAMESPACE ""
Options +FollowSymLinks
ErrorDocument 400 /cgi-bin/koha/errors/400.pl
ErrorDocument 401 /cgi-bin/koha/errors/401.pl
ErrorDocument 403 /cgi-bin/koha/errors/403.pl
ErrorDocument 404 /cgi-bin/koha/errors/404.pl
ErrorDocument 500 /cgi-bin/koha/errors/500.pl
<IfModule mod_gzip.c>
mod_gzip_on yes
mod_gzip_dechunk yes
mod_gzip_keep_workfiles No
mod_gzip_can_negotiate yes
mod_gzip_update_static No
mod_gzip_temp_dir /tmp
mod_gzip_minimum_file_size 512
mod_gzip_maximum_file_size 1000000
mod_gzip_maximum_inmem_size 1000000
mod_gzip_handle_methods GET POST
mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader Content-Type:image/*
mod_gzip_item_include file \.js$
mod_gzip_item_include mime ^application/javascript$
mod_gzip_item_include mime ^application/x-javascript$
mod_gzip_item_include file \.php$
mod_gzip_item_include mime ^text/html$
mod_gzip_item_include file \.css$
mod_gzip_item_include mime ^text/css$
</IfModule>
<IfModule mod_deflate.c>
# Compress content with type html, text, and css, ...
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
DeflateCompressionLevel 9
# Properly handle old browsers that do not support compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
<IfModule mod_headers.c>
#properly handle requests coming from behind proxies
Header append Vary User-Agent
</IfModule>
</IfModule>
RewriteEngine On
# Uncomment to turn on rewrite logging
# RewriteLog /var/log/koha/koha-intranet-rewrite.log
# RewriteLogLevel 1
RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
RewriteRule (.+) $1?%1%2 [N,R,NE]
RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT]
RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
servername localhost
5) Restart Apache /etc/init.d/apache2 restart
This failed (I forgot the error message, but can recreate it if required).
I also have Webmin installed and configured, as part of the Koha install - if this should be relevant.
I have also looked at this article, but couldn't gleam from it a resolve for my problem:stackoverflow article
If anyone can tell me why this didn't work and how to make it work, I would really appreciated it.
Thanks
Jurgens
This isn't a koha specific question at all. It is how to get your apache server answering on your LAN.
First off do an sudo ifconfig
To find out what the IP of your server is. Then set apache up to listen on that address.
There is nothing special about Koha in this regards, it is just a website. So you just need apache2 answering on the IP number that is on your LAN. Not 127.0.0.1
Also webmin is not needed by Koha
You really dont need all these configurations, if you used the live dvd everything has been configured on it.
All you need to do is to go to your terminal and run an ifconfig to see the ip address on your machine, it is this ip address that you will enter in the address bar on all other systems and they will see your Koha.
Please do check if you have the same network on both of your koha server and client computer... In our case, koha is accessible via LAN using its ip addresses.
you may also need to check the network configuration itself. for example, if your client pc cannot ping any request to the koha server then your network configuration might be the problem.
our koha work over LAN without any configuration on "koha-httpd.conf".