How to check whether your site is served in
If you find the bloew line in the returned response, your site supports
#linux #curl #gzip #seo
gzip
or not by using cURL
linux command:curl -H "Accept-Encoding: gzip" -I https://www.google.com
If you find the bloew line in the returned response, your site supports
gzip
:content-encoding: gzip
NOTE:
gzip
can speed up your site speed tremendously, sometimes by 90% compression! It also affects your google rank.#linux #curl #gzip #seo
In order to compress a file with level of 9 (maximum level of compression), you need to
set an ENV variable. In order to not clobber the file system environments you can use pipe in your command:
#tar #gzip #compression_level
set an ENV variable. In order to not clobber the file system environments you can use pipe in your command:
tar cvf - /path/to/directory | gzip -9 - > file.tar.gz
#tar #gzip #compression_level
tarfile
is a python library to read and write gzip`/`bz2
compressed files.How to read a
gzip
compressed tar archive and display some member information:import tarfile
tar = tarfile.open("sample.tar.gz", "r:gz")
for tarinfo in tar:
print tarinfo.name, "is", tarinfo.size, "bytes in size and is",
if tarinfo.isreg():
print "a regular file."
elif tarinfo.isdir():
print "a directory."
else:
print "something else."
tar.close()
Create a compressed file:
with tarfile.open(dst, "w:gz") as tar:
print("Archiving " + src + " into " + dst)
tar.add(src, arcname = os.path.basename(src))
NOTE:
the flag of w:gz
opens the destination in write mode. Used to create a new tar file.#python #tarfile #tar #bz2 #gzip