I am facing mod_pagespeed image rename issue while page optimization - mod-pagespeed

i have mod_pagespeed implemented on my website. but it optimizes the images it changes the name to a very long file name. Can this hurt search engine optimization because i am getting good traffic from image search.
Can this image rename prevented in configuration file some where. i am using latest version of page speed (1.8...)
Any help is really appreciated.

My server is currently running PageSpeed version 1.8.31.4-4056. In our pagespeed.conf file, I see the following entry:
# Many filters modify the URLs of resources in HTML files. This is typically
# harmless but pages whose Javascript expects to read or modify the original
# URLs may break. The following parameters prevent filters from modifying
# URLs of their respective types.
#
# ModPagespeedJsPreserveURLs on
# ModPagespeedImagePreserveURLs on
# ModPagespeedCssPreserveURLs on
Looks like if you uncomment the last three lines, the URLs will be preserved. You'll then have to restart Apache.
I found some documentation about the settings here: https://developers.google.com/speed/pagespeed/module/config_filters#preserveurls
Unfortunately, preserving URLs disables some other useful features.

Related

How do I serve MathJax from a local Happstack server?

I'm not a developer/programmer. I'm just someone trying to use Gitit to take notes. I've got it to the point where it runs on Windows, but the math looks best using MathJax. I don't want to rely on a remote CDN to get the MathJax working (power cuts and internet disconnections are very frequent here). The author of the app mentions it can be setup in "4 lines of code" in Happstack:
mathjax-script: https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
# specifies the path to MathJax rendering script.
# You might want to use your own MathJax script to render formulas without
# Internet connection or if you want to use some special LaTeX packages.
# Note: path specified there cannot be an absolute path to a script on your hdd,
# instead you should run your (local if you wish) HTTP server which will
# serve the MathJax.js script. You can easily (in four lines of code) serve
# MathJax.js using http://happstack.com/docs/crashcourse/FileServing.html
# Do not forget the "http://" prefix (e.g. http://localhost:1234/MathJax.js)
The link to the tutorial is broken, so I'd be grateful for some assistance. Is there is any MathJax configuration I need to change, or simply extracting the files will do? I'll be writing lots of math in gitit. I'd prefer not to set up Apache etc. to serve MathJax. Gitit already uses Happstack, I'd prefer using that. Thanks!
EDIT: Just to be clear I'm not sure how to assign the port 1234 to serve this script
Ok I got MathJax working using portable Apache and the MathJax archive downloaded from docs.mathjax.org. The URL needs to be of the form (assuming you extracted the files into apache2/htdocs/MathJax):
http://localhost/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML
I wanted to keep this lightweight by reusing the same instance of Happstack as Gitit, but that seems beyond my skills/available time right now.
EDIT: Just found out that ghc will pack everything into one exe when building. So I doubt it is even possible to use the same Happstack instance, as the root directory of the server doesn't exist?
From the documentation, the static directory should work just fine:
On receiving a request, gitit always looks first in the static
directory (or in whatever directory is specified for static-dir in the
configuration file). If a file corresponding to the request is found
there, it is served immediately. If the file is not found in static,
gitit next looks in the static subdirectory of gitit's data file
($CABALDIR/share/gitit-x.y.z/data). This is where default css, images,
and javascripts are stored. If the file is not found there either,
gitit treats the request as a request for a wiki page or wiki command.
So, you can throw anything you want to be served statically (for
example, a robots.txt file or favicon.ico) in the static directory.
You can override any of gitit's default css, javascript, or image
files by putting a file with the same relative path in static. Note
that gitit has a default robots.txt file that excludes all URLs
beginning with /_.
(source: https://github.com/jgm/gitit)
Download the MathJax.js file from e.g. cdn.mathjax.org and place it in data/static/js/MathJax.js. Then change the config you quote to:
mathjax-script: http://localhost:5001/js/MathJax.js

KML relative URL warning

I have this little piece of KML code which shows an image when clicked on the placemark, all images i have are store locally, and it works fine when using the .kml file it self.
Once the file is compressed into .kmz i'll get a warning (yellow marked) on the first line of the CDATA, covering some of my text.
It says: "This balloon may be using incorrectly formatted image URL"
All of my images works fine, they are not missing, and the relative URL is correct, but the syntax is not.
Anyone out there know of a solution to get rid of that hardcoded message ? or even better how to "tune" the code, so this warnings don't show :)
I've seen a couple of examples, stating it should help, but none suits my need, unfortunally.
This was some of the solutions i've looked at, but still not got it working.
Option 1: Fix the URLs
Your base URL is one directory down from where you thought it was, so you can simply add “../” to the beginning of each offending relative URL. This works fine in earlier versions of Google Earth as well, because older versions will look in both directories (and as a bonus, your content will render faster in older versions).
To fix the above example, we’d change:
<img src="images/image.png”>
to
<img src="../images/image.png">
Option 2: Add a <base> tag
As with any other browser, you can add a <base> tag to your HTML to set the base URL of that content. The href parameter of the <base> tag must be an absolute URL, so you’ll have to hard-code your server name and path. Adding the <base> tag to your BalloonStyle can fix all of your URLs in one go.
To fix the above example, we’d add: <base href="http://host.example.com/kmz/somelayer/"> to the BalloonStyle (or description, if we only have a few affected placemarks).
Option 3: Move the files
If you can’t change the balloon content, you can still correct it by moving the resources it points to into the correct locations. Depending on the URL, there are a couple of ways to do this. In our example, you’d move or copy the “images” folder and its contents to the KMZ archive. If the offending URL was “../files/another_image.png” (which should have been “../../files/another_image.png”), you could move or copy the files folder into the somelayer folder to fix the problem.
In many cases, though, there will be many layers all referencing the files folder, so moving the files folder into each layer folder can get tedious. If you have access to the web server configuration, you can solve this by adding an HTTP redirect from each incorrect location that redirects up a directory. You could also move the KMZ file up a directory, but this will change the URL that people must use to access your KMZ file.
I wanted to look at your KML to see if it was properly formatted and test it on my end.

What does .sprite file refers to?

I'm using Liferay Portal 6, The .sprite file is not specified in the source code, however, it's included in the URL with a slash dot, then it's blocked by a security program.
When I delete those file in theme/docroot/images and I deploy the project, they are generated again.
I would like to know how to manage those files or rename them?
You can open those files: It's combined images - look up "CSS Sprite" for a thorough documentation. They're used to limit the number of requests that go back to the server. Without sprites, you'd have every theme image loaded individually. With them you only need the sprite once, resulting in a significant performance boost: You want to have as few http-requests per page as possible, and sprites are one automatically handled way to help you achieving this.

How to link to local images on Node.js version of Tiddlywiki?

I'm using the Node.js version of TiddlyWiki, and I'd like to link to images on my filesystem.
The documentation listed here doesn't work; in the [img[path]] tag, for the path part I put something like /Users/documents/ken/path_to_image.jpg yet nothing shows up in the tiddler.
My wiki exists in /Users/documents/ken/wiki.
I know this is an old post, but zacts stated that you can use a macro plugin or simply use the [img] tag to point to the relative path of the image from the tiddlywiki.html file, but the op is using the node.js version, and zacts apparently didn't read that. There is no tiddlywiki.html file for TiddlyWiki on node.js. That only works with the static .html version of tiddlywiki, not the node.js version.
Currently there is no way to point to a local file through the node.js version of Tiddlywiki as node.js is not a webserver, therefore it does not see subfolders like /images/ off of the root url. The only way is to run a parallel web server on the same machine and use the full web url to the images served up from the web server.
In case someone else stumbles across this problem:
I could not find this documented anywhere, but what seems to work is to just copy the image in the tiddlers directory, then restart the nodejs server, and search for the image title from tiddlywiki. There will be a tiddler that contains that image, that you can edit at your leisure.
Alternatively, copy the image as image_name.png (or image_name.jpg) into the tiddlers directory, and create a image_name.png.meta text file with the following contents:
title: image_name
type: image/jpeg
Upon restart of the tiddlywiki nodejs server, a tiddler with title image_name which contains the image will be there.
If you are using the Node.js version, you can simply put it in the ./files folder, and then use [img[. /files/xxx.jpg]] to reference it.
I had this same issue recently, and I found a neat little solution for it. Let me send you the links, and I'll post the snippets here.
I happened to stumble across this tiddlywiki image gallery homepage that linked to a macro plugin that lets you link in local images. Here is the link to the tiddler for the plugin: http://www.richshumaker.com/tw5/tw-photo.html#External%20Image%20Path. Here is the original TiddlyWiki google groups post of the plugin for this: https://groups.google.com/forum/#!msg/tiddlywiki/ChRV6sjQpn4/bCm35_XhGmkJ.
I hope this helps! =) (note: when I get more time I may clean up the formatting of this post).
It is very simple, you use _canonical_uri field
_canonical_uri field
The field value is something like "./wiki/path_to_image.jpg" (mine is "./files") in the same level as the tiddlers folder. I did not experimented with files outside the root folder of the wiki. The dot in the path might be ommited.
The content type might be "audio/mp3" "image/jpg" look at the "parser" shadow tiddlers. Your Browser might support more content types like "audio/wav" but you would have to add this line to "$:/core/modules/parsers/audioparser.js" For example. Might be the same thing for images. Check your browser support.
I really do not know why this fact is so obscure, but it work wonders.

Best practice for white-labeling a static web site?

I have a directory structure with files under directory 'web', which represents a white-label web site (html files, images, js etc.).
I also have some twenty different 'brands' let's call them 'web-1', 'web-2' etc. each containing specific files that should override the files in 'web' for a specific brand.
Apache is configured to find the files for each virtual site i in document root 'website-i'.
In order for each 'website-i' to contain content like 'web' with the overrides for brand 'web-i', my build script first copies all of 'web' to 'website-i' and then overrides it with the source files from 'web-i'.
There several problems with this approach:
It takes time to copy the files.
It takes a lot of disk space
Adding a new brand requires adding to the script.
Is there a best practice for doing this in a way that does not require duplicating files?
(with Apache and Linux)
Well, the best solution is with pretty simple server-side code but I'm going to assume you've already rejected that, maybe because you haven't permission to run code on the server (although if your hacking the config then you probably do).
A solution just in config could be to make it serve from the default root but rewrite the url if the file exists in the proper dir ...
RewriteCond /web-1/a_file -f
RewriteRule ^(.*)$ /web/$1
But you'd have to do this for every file in every brand. You might be able to be more clever about it if the files are stored in a dir that's the same as the hostname but that's getting too complex for me.
Seriously, server-side code is the way to go on this...
Strangely enough, a work colleague was in pretty much exactly the same situation a couple of weeks ago and he eventually rewrote it as PHP. Each site is a row in a database, one page which pulls out the changed text and urls for images, etc. and falls back to a default if there's nothing there.
Having said all that. Using links, as you say above, solves problem 2, probably much of 1 and I don't think there's a way around 3 any way.

Resources